Minor bug fixes to train and loco separation code