Use sementically correct types
Summary
Currently, the variable types are good enough to get the code working, but not always "the best ones" in term of semantics. This can be improved while going through the refactoring.
[Migrated from this GitHub issue which started with that comment.]
What is the expected correct behavior?
Variable types are chosen according to the variable semantic.