Refactored the application with new classes and threads.