fixed and cleaned up the traversing.js module