Small fixes, added documentation to undocumented stuff, fixed bugs.