Bugs fixed in dynamic routing algorithm