Huge refactoring and simplification of frontend code.