[#30] refine directory processing, use expand-file-name instead of file-name-as-directory to simplify code