Code clean up. Prep work for python 3 support.