Clean up main code.