You should stick a bit with the syntax, in S2C[] and C2C[] the Return[] is syntactic sugar. I'm not sure whether the indexed Part[]-Operator [[]] like in
do really work as you intend it (Part[] normally goes unindexed) and last but not least, it's better for [\pi]tOut and [\phi]tIn to use a Block[] structure, i.e. instead of
fOut[...] := (a = 0; b = 0; <more expressions>)
please use
fOut[...]:= Block[{a=0, b=0}, <more expressions>]
Is there some test case you know the result for to check with?