Revert file transactions in reverse order.

Revert in the reverse order in which the transactions were originally
performed.
Fix url template tags for Django 1.5 support