Type hinting fixes

@icewind1991 @DeepDiver1975 please review
changes suggested by scrutinizer