Lots of file additions and code fixes