Moves many helper functions from views.py to helpers.py.