Code amended in many functions.
Lots of changes.