Fixed cross-platform porting issues