Code cleanup, including switch to === in many conditions