Move main code back into main function.

Apparently the setup script doesn't like not having a main function...
Default format should be a key in the formats dictionary.