Replace ugly cast with typedef.