This should work. Fixed some things in entity and fixed mongo.php