Port some code from Passenger Enterprise