Added type checking for if-empty and def-rec.