Added database and logging functionality