Fixed a few glitches and added more documentation