added memdb and database and stuff