bug fix and cleanup in views.py. [MJ-374]