Fixed #1, added related tests. Minor touch-ups and documentation.

Signed-off-by: robhol <email@robhol.net>