major refactor and improvements