Improve CPU usage of main process by sleeping