reorg_function (Ema)

Rebased https://github.com/elkarte/Elkarte/pull/450 to make it look readable in history :)