Cleaning up code and setting up schedule service