refactor execution, add grep handling, Fixes #4