Profile image handling and various refactoring