Fixes and optimises the generation of the responsecode which was empty in certain cases.