This is working code.
This is the final cleaned up version.