Fixed bug where a protocol warning error would appear. Also, cleaned up some code.