added a few refactors on django.core files