lots of changes, cleanup etc