Cleaned up code for: https://github.com/Sammaye/MongoYii/issues/217