Refactor Dialog code for less code to write.