Switching from endless loop to app idling.

Replacing the endless repeat with an on idle statement. Timing probably
needs more tweaking to lower CPU usage.