Complete rewrite of __init__.py