Found the bug (uninitialised fgPid). Switched to Release build. Functionality complete - now for code cleanup