Fixed a couple of bugs that caused the controller to get stuck.
Improved Demo Code.