Address many pylance smells. Ignoring some I don't know how to handle, added some TODOs for handling others later.