All database-related changes (from Tommy's branch)

Includes changes to collections, models, database.js, utility.js, etc. from Tommy.