expand pear workaround to catch more notices 
Remove some duplication
Move formatter-related functions into their own class
remove some duplication