Refactor frontend into modules