several bug fixes. Added some very basic API documentation.