Fix code for latest libraries and compiler