Optimize parameter encoding a bit and also fixed to make new unit tests pass