Badges avatar and code refactoring
More fixes and refactoring
Merge branch 'badges'