Issue #45: Refactored database queries to use foreignKey__fieldName in

order to reduce database queries.