fixed some bugs found by functionalExamples