lean: fix head optimization