traverse: Replace traversal buffer with alloca for thread safety