Basic working scenario. Test and other cleanups to come.
Unit tests and other small cleanups.