lots of rewriting ugly old rushed code

not really that much in the way of new features.