lots of changes, mostly cleanup