Fix for realpath. Not available on all systems. dirname should be