Compatability fixes for mongoose 3.7.x