RCD spaces: Splitting theorems and applications