refactor code to simplify ui initialization and remove blocking calls that prevented ui from displaying