polish up the sources, add a ton of unit testing