initial checkin & lots of bugfixes for plugin