Add more extensive type annotations so we get improved type checking.