Tweaked non-py25 compatible code.