Cleaned up and updated to use MongoDb.