Make build cm compatibe and some cleanup