Adding some tidy to the ui and logic for backend api