This function can be renamed to just init(), and invoked as per a normal initializer. This also allows the callback to be dropped, and the numerous references to callback(dialog) to be removed. Only a single callback(dialog) should remain as the last statement in the new init() function. Net result should be even simpler again :)