Restored some code accidentally removed and removal of some nonsense code.