Fixed API and Python3 bugs.