Complete rewrite. Pushing up to version 0.5.1.