fix various filepath issues (including #541)