Refactoring

Refactor some of the classes to use accessor method instead of directly using the instance variables.