Bug789 v1.2 part1

Updated PR with fix of build in debug mode.