Tidied up code and UI