Properly #ifdef debug-only code

Change-Id: Iebf7ed1fb034ab2c2bee36ca6bf23408bf060d8d