Bugfix and doctests