Added some Exception Handling and Refactoring

Database and tables are created if they don't exist. Changed names for
certain objects and variables.