Misc. code cleanups. Change of defined to exists in last sub