Refactoring and UI Fix