Wrapped all scopes in lamdas to comply with rails 4. This also prevents scopes from evaling when the class is loaded, possibly triggering other class loads.