Fixes for plAvatar

This takes care of a few issues in plAvatar that were pointed out by the code analysis.