Complete rewrite of __init__.py
Merge branch 'rewrite'