Fix file-exists-p and minor performance improvement.