Fixes N+1 queries. Changes column names to be PG compatible