fixing script to work with symlinks, adding missing headers