fix typos and python3 compatibility