Commit taken from [1]. [1] https://github.com/lnls-dig/halcs/commit/d409d183ba4b4c49a4b8be0ab6900e01e8f73390