Added workaround for what I believe to be a gcc bug.
Will ask on stack at some point if this is expected behaviour.