Dynamically finds the correct number of balls to give a frame rate between 50-55 fps.
Minor optimisations and code tidy up.