This method is complex enough to have a comment describing what it does.