Fix endless recursion in calc_rail_dir() (fixes #14)