So I stumbled on an error in Drupal 7. It cluttered my database log.
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /var/www/includes/entity.inc).
I knew that it was about loading entities in some of my code, but I couldn't trace it back by this error. I fired up the old Xdebug. Since I used it through netbeans it showed the same results when the results were empty and when first element of array had NULL in it's value.
Problem was that the value came from admin form. So when I loaded the value using variable_get, in case of empty the result was NULL as default for variable_get. When I entered 0 for default value then that fixed it all. So if you stumble on this problem make sure your entity loads (including file_load function) won't have any NULLs.