Can someone help me understand this code?
# Remove trailing ?
RewriteCond %{THE_REQUEST} ? HTTP [NC]
RewriteRule .? /%{REQUEST_URI}? [R=301,L]
RewriteCond %{THE_REQUEST} ? HTTP [NC]
RewriteRule .? ^%{REQUEST_URI}? [R=301,L]
Isn't going to work, because ? is a reserved character for regular expressions and you'd need to escape it along with the space. Try:
RewriteCond %{THE_REQUEST} \?\ HTTP [NC]
RewriteRule ^/?(index\.cfm)? /? [R=301,L]
Additionally, you want this rule under your # remove trailing index.cfm rule, and not at the very bottom.