final (but not complete) frontend refactoring