Refactor of API and XML node manipulation