Add exception support and IN/OUT support

But something is still going wrong with IN/OUT