Refactored out safe accessor methods to reduce code duplication and make it easier to read and maintain
Fixed merge conflicts