Refactored local database frontend to enable reuse

of code in the leveldown implementation