lib/functions: fixed MacOS X incompatibilities