Remove obsolete code and some code cleanup.