Fix several compile errors when specifying -DDEBUG globally. Previous GCC versions were more liberal and the code thus compiled. Also initialize/reset a count variable correctly.