Added ncall function and tidied up ninvoke