fix for #65; removed IntegrityErrors where possible; cleaned up some imports; make all tests pass even witch caching enabled