Type safety fixes.