Refactor to eliminate realpathSync