Bugfixes and new documentation

A lot of FIXMEs (also with solutions) added to the code.