Restructure main class and add MySQL connection