Slightly simplified code for order finalization.