fixed core functions for python3 compatibility