Refactor keydef reader into a separate filter