Refactoring gui and referencees