Fixed some compatibility issues with Django 1.5