Extracting a few constants

Extracting a few common constants and bits of code.