Remove complicated non-recursive code