Some clean-up of the refinery code