type safety fixes