Added realpath to dirname usages

Same as #766, but for the v1.0 branch