Bugfixes for compilation with gcc