Bunch of small changes and some dead code killing.