Several bugfixes to conform to the custom user model.