Improve support for handling IN / named params in functions
Based on work by Bert Thomas <bthomas@brothom.nl>