Add support for custom ObjectId objects
Replace lodash type-test calls with native calls
Clean up trailing end-of-line whitespace
Bugfixes and cleanup