Clean up of the setup.py

Removed a lot of code duplication.