couple bug fixes, now the doctest runs without error