Changed engine function to use the module pattern
Updated relationships between in and out variables