Improve frame time stability by taking a few unnecessary repeated calculations out of the main scene loop.

Also uses a wait event to sleep rather than a Thread.Sleep to allow the loop to be interrupted in a more controlled manner when necessary.