Refactor frontend, backend