Added database functionality (finally ;))