Fixed some bugs in mac version