extract smaller methods, removing duplication
adding MSG_ prefix to the string constants used for logging
reorder constants/fields