lots of refactoring (with js its such a pain that its more like refcuktoring) - probably several broken things now...