fix openifnot function
move some osx stuff in appropriate place