Rework OSX code, things should work a bit better now