Removes duplicate code and flattens the structure

- Removes duplicate code (A lot of the code had been written twice: once for creating a new poll and second time for editing an existing one)
- Flattens the structure (nested ```if () {``` clauses make the code difficult to read)
- Removes some unnecessary code