Remove global variables, add files for gcc building