Fixed some porting bugs.