bug fix + debug output

Change-Id: I438d01cbc98d041aa054cfde8020d3527c215cfb