major refactoring of most everything