Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Move the compacting of the ways back to the top, delete the unused ways at this point and also call the function again after pruning segments.