Add a working setup.py!

Minor code rearrangements so that the imports work again.