Fix some mistakes and compilation warnings