Detection of Parameter Direction in DeriveParameters method.

This detection is necessary because currently this method defaults all parameters with Input direction and when using functions that have OUT or INOUT parameters they aren't updated.
(PR - updated for current master)