Loading dialog & refactoring