Production Flexibility, Misallocation and Total Factor Productivity