Fixes major bug in initializing visited flag