Database optimizations, bug fixes

Did some database optimizing regarding named scopes and eager loading.

Fixed a bug where ApplicationAssignment#index would display all application assignments, instead of only the ones relating to the current user.