Adds a little more documentation and cleanup, fixes bugs