Added some fixes for guarding against stupid incoming data [ ie non protocol conforming ]