Some improvements

With this improvements the code became usable in one project I am working on.

Please double check for the following reasons:
- I am using SQL Server as database backend
- I don't master django enough to be sure that some assumptions I made are correct.