Clean up internalMode function.