fixed recursion problems which lead to VM crash on MacOSX