Remove debugging code
Whitespace
Speed up metadata value constraints with raw SQL

This cuts the request time in half because we avoid the COUNT query that a standard ActiveRecord 'where' runs before the SELECT, and with all the joins this can save considerable time.