complete refactor

I rewrote most of the code. Please see diff for changes.
I tested this code with the Django Admin and with import/export of fixtures (it didn't worked for both before).