Seems to be working.
Important note: Do the color management first, then apply the transfer function.