Fix lots of disgusting bugs
More critical bugfixes for the reachability code.