Solve Mac bugs
Merge pull request #691 from YouLu/Mac