General changes, fix some problems and clean up a bit.