Refactored and commented the code further for support Doxygen documentation.