Added debug messages around the optimize code