Changes to support user-defined functions.

Changes made while working on wb-user.