Massive cleanup, almost ready to submit