Debugging and documentation

Some small fixes added during testing (I'm still testing). Added more
documentation. More to follow.