Refactor OCdialogs.

Quite some work.

Once I tamed it, it was pretty easy to use though.

Fixing #2557

@tanghus

Released under MIT-License