Better traversal, fixes bugs