Frontend refactoring. Part 1.