Added DB and logging functionality