Made some changes to work better with g++