Things got done at last. Fixes #9, improves implementation for #5, #6