Fix compile and adapt code to be similar to 1.7/master