Added some database logic (unfinished).