gcc version detection and major refactoring