fixes to models, adding some caching, and fixed some n+1 queries