Refactor some of the classes to use accessor method instead of directly
using the instance variables.
[Fixes #128]