Fixed a bug in the reachability code