Web application refactor

Removed some more code duplication.