Changed the main loop to ScheduledExecutor.