 			
 			trace("Zlib.compress. compressed.length: " + compressed.length);
 			trace("Zlib.compress. compressed: " + compressed.toString());
-			
+
+			compressed.position = 0;
 			return compressed;
 		}
 		

	public class Zlib implements ICompressor
	{
		/**
		 * Uncompress the given ByteArray.
		 *
		 * @param	data
		 * @return Uncompressed data

			stream.next_out = uncompressed;
			stream.next_out_index = 0;
			
			stream.avail_out = outBytesLength;
			stream.total_in = 0;
			
			
			err = stream.inflateInit();
			checkError(stream, err, "inflateInit");

			var outcount:int = 0;
			while (true)
			{
				// force small buffers
				stream.avail_in = 1;
				stream.avail_out = 1;
				
				err = stream.inflate(JZlib.Z_NO_FLUSH);
				switch (err)
				{
					case JZlib.Z_STREAM_END:
						// completed decompression, lets copy data and get out
						trace("Zlib.uncompress. inflation stream ended");
						break;
					case JZlib.Z_BUF_ERROR:
						stream.next_out_index = 0;
						stream.avail_out = outBytesLength;
						break;
					default:
						// unknown error
						if (err != JZlib.Z_OK)
						{
							if (stream.msg == null) {
								trace("Unknown error. Error code : " + err);
							}
							else {
								trace("Unknown error. Error code : " + err + " and message : " + stream.msg);
							}
						}
				}
				
				outcount++;
				//trace("Zlib.uncompress. outcount: " + outcount + ", stream.total_out: " + stream.total_out);

				if (!checkError(stream, err, "inflate"))
				{
