This have been rewritten and will be part of the next PR.