Correct implementation of gcc specific internal functions (take 2)

This pull request implements what suggested in #107

/cc @kibergus
/cc @matthijskooijman