Added free resources used by Function.
Starting VM refactoring.