Moved some ingot pile code around to make it less cluttered