Docs: Code fixes, highlighting and typos

This is the squashed version of #1369.

Closes #1369.