added node traversing code, speed improvements