Fix some platform dependence

@seriousamlqz Please review