clean up some constants, improve double letter logic