Improve docs and fix pyflakes warnings