Fixes an issue with format in upper case.
Does some clean up of the code.