Fix some bugs in avatar support.