Reorganize gui and add functions