Move most constant handling code to new constants.c file