Added spinner for loading views and code refactoring.