Cleanup of code and fix for gcc 3.4.x, screw 4.x for now