Added node version checking and further refactoring