merged changes made by Ion in sec 3, 4