Fix for Darwin
readlink -f is not the same on OS X. Use custom implementation.
Personal fix ups