Fixed issue of using same key twice
Fixed a bug with incorrect message size