Fix compiler errors and warnings
Merge remote-tracking branch 'upstream/master'