Switch to setuptools
Explicitly order write operations

With this change, the writes are guaranteed to be in a specific order.
Fix some PEP8 issues