Restructured code, started on ToC