Address @trustin's comments and also fix a bug that is encoundered when a bad message was received