Dave/major refactor