Removed unnecessary loop. Added debugging toggle.