Fixes #6560 - Extract puppet parsing logic