Some bugfixes and some work on documentation