Detect and close empty where contexts in the right place.