Fixed database bugs and added new function to application.sql