Refactor the code to granular classes
Add more strictness checks on the types