Fixing memory leak in Formatter