Various fixes and clean up.