a bunch of additions and fixes