doctests for functors, minor bugfixes