Finalize changes, remove stray debugging code and remove some changes that are no longer needed.