Moved file reading functionality into local functions
* it was moved into functions local to the respective compilation unit to improve readability
** splits DOM tree construction logic from the actual purpose of the external function