Minor code improvements

Getters used instead of accessing attributes directly, stricter access
levels, attributes made final where possible, attribute replaced with
local variable. Backward compatibility was preserved in all cases.