Don't use deprecated API. Fix compiler warnings. Cmake cleanup. (Missing changes from 44ea1ea)