Cleaned up the code. Reformatted comments to comply with godoc. Migrated tests to using convey. Other minor fixes.