kwchen3 paulkim6: Refactored segments of Avatar code