implement head/tail/some 'preset' filter & various fixes to gfilter()

This is an initial attempt at a working head/tail/some preset filter for gfilter(). The implementation is NOT yet ready to be included upstream. See discussion in issue #29 .