Added some more documentation.

Also incorporated a couple bug fixes from Lea. Thanks!