500 fixes

http://manage.dimagi.com/default.asp?86411