Add IsValidModule in module manager.
Fix compile errors and minor typos.