lots of additions and fixes