Added asserts to check output types explicitly.