Include inactive users in exports

+ a few small refactorings

http://manage.dimagi.com/default.asp?122380

@czue