Refactoring.

Improves atomicness of signal handler.
Django 1.6 support.
Less invasive of the model.