Wrote views.py. Additional small refactorings.