tested in Python 2.7; fixed Unicode support