Added loading indicator. Did some refactoring.