begin converting functions to use defun() macro. replace magic numbers with enumerations.