Color calibration and white balance


I'm looking for a few clarifications.

I read in a previous thread ( that white balance values are applied by multiplication using values in "cam_mul". In my experience, this isn't the whole picture. For example, setting "cam_mul" to [0, 0, 0, 0] does not produce a completely black image. I tried looking at the codebase to find out what is happening, but was unsuccessful. Additionally, am I correct in assuming that white balance is performed in the camera native colorspace before any conversions?

Finally, how is cam_xyz used? Starting from the RAW bayer image, the sequence of operations in my opinion are:

1. Get RAW bayer image
2. Black-level subtraction
3. white balance by setting cam_mul (custom values)
4. demosaic (order of steps 2 and 3 may be interchanged)
5. convert to xyz (matrix multiply cam_xyz)
6. convert to sRGB (matrix multiply standard xyz->sRGB)

However, the result looks very different compared to the sRGB image output by Libraw. Is there anything I'm missing? Thanks in advance for your time.