Fix a lot of bugs on linux platform