My changes on XD-163

Did not rebase on purpose.

One commit for each so you can cherry pick