Improve Python 3 compatibility (except Type as var)