Simplify the code a little

Extract common code between rnn and rntn to minimize duplication