terra fixes for dynamic function generation