Rewrote match to ensure nested parameterized functions are handled properly, resolves #448