changed some checks to a more defensive coding style to find problems faster with misconfigured clients