secure gravatars and minor refactor