Fix many issues with new code.