Cleanups and simplifications to increase code clarity