added keystore, refactored/prettified mongo access