reorganise, cleanup and move to cmake build