See line 1362. I agree that it is not very clean...