Adding better debug log and fixed array ref error in 32bit