C++ Bugfixing