Bugfixes for c++ backend