Lots of additions and fixes