Improve backward and forward traversing algorithms