Clean up main code