Fully functional code.
See README.md for more details.