small changes and python3 compatibility