Fix high CPU usage issue (closes #28)