Large refactoring of edit frontend