Loading icon

Also code refactor