more working parts and code now largely finished refactoring