Updated the use of realpath() for consistency