reorganize editor code a bit to something less awful

It is still not nice, but at least on the right track?