Minor modifications for better Python 2/3 compatibility