lots of bugfixes! progress on #29