Refactored migrations for 1.7 and added Python 3 unicode compatibility.