Reverted function_generation.php to commit 524eab5c65 and applied some changes from f8d2359d37 in order to prevent all returned objects from methods and functions from causing segfaults as described on issue #17.