Fix for ghost nodes

See code and initial comment.