assorted optimizations
removed some unused bits
Merge commit 'd063015af95f43a00e8d37a7eeeb112d4422968e'