Minor fixes and Python 3 compatibility