Fix cancel button being unclickable.

Also code cleanup.