What was essential to the factory system by increasing efficiency and lessening the cost of production?