Modified to work with gui and deleted wasted files.