OS X + fix some bugs