Continuation of #42, rebased properly, and with feedback addressed.