Make crazy path manipulations more sane
Mac fixes script.

Not sure if this is the right place for it to be honest, but it's going
to live here for now.