removed dead code, enhanced encapsulation.