Fixed a few bugs in editor. nearly working.