Code cleanup, minor fixes and improvements

Incorporating @schriftgestalt’s suggestions