Added validation to avoid unnecessary compilation calls.