a few new OS X functions and a cleanup