Clean up of the code to reduce the number of warnings and the quantity
of outright duplicated code.