Reorganize frontend code