Frontend code cleanup, formatting and documentation.

Additionally, added a confirmation dialog to the cancel flow.