Directly accessing ivars

Replaced any direct access to instance variables with accessor methods
to adhere to best practices.