lots of minor include changes. Believe it or not it's miracle that VS was compiling this code