Fix RailSystem termination behavior

This also fixes an unrelated typo bug
Optimize component lookup in rails
Remove outdated test package
[trivial] Fix spacing
Add logging to rails
Fix leftover code bug
Fix straight segment calculation bug
Change variable names for readability