Restructure functions and add database connection functionality
Implement basic user handling