Python 3 support and general cleanup