Added more input/out variables, added comments for calculation workflow