Doctests, bugfixes