Fix compile issues and UTs