Fixed some compilation errors and warnings from gcc