Frontend stuff and backend refactoring