Refactor to remove separate thread for cherrypy