Rework avatar URL function

This fixes up the last issues with the `get_avatar` function. See #35