Refactored class, splitting into constituent functionalities.