Modified database and cleaned up a little code