Refactored pygments stuff into func