Fixes two causes of transport related crashes

Fixes #4790 and also fixes #5270