Tweaks to the code to make the demos run smoother