Some refactoring

1. Move DB initilaization into IF statement (where it's actually used)
2. Fix on MongoDB genertion for AppHarbor