public static Collection<Message> translate(final ByteBuffer buffer, Client client)
	{
		//logger.info("Beginning Translate");
			
		byte command;
		byte[] lengthBytes = new byte[MESSAGE_HEADER_LENGTH];
		byte[] data;
		int length;
		
		Message msg;
		
		boolean processing = true;
		
		Collection<Message> result = new LinkedList<Message>();
		
		while(processing)
		{
			//Switch processing flag to false, exit loop
			if(!buffer.hasRemaining())
			{
				processing = false;
				break;
			}
			
			//Mark where we started, in case we reset
			buffer.mark();
			
			//Get the command of the message
			command = buffer.get();
			
			//Instead of checking for a remaining of 3 or more, two if blocks are used to allow for the potential of having certain commands be known to have no data
			//Check command to see if it has a fixed length
			//Else, get the length
			
			if(buffer.remaining() >= 2)
			{
				buffer.get(lengthBytes);
				
				//Convert length byte array to length value
				length = ByteConverter.ByteArrayToUnsignedShort(lengthBytes);
				
				if(buffer.remaining() >= length)
				{
					//read off the rest of the message
					data = new byte[length];
					
					buffer.get(data);
					
					//Add message to the result collection
					msg = new Message(command, data, client);
					//logger.info("New Message: " + msg);
					result.add(msg);
					
					//Compact the buffer (remove the message) 
					buffer.compact();
					
					//Flip the buffer, prepare it for reading
					buffer.flip();
				}
				else
				{
					//buffer does not contain a complete message, reset it
					buffer.reset();
					processing = false;
				}
			}
			else
			{
				//buffer does not contain a complete message, reset it
				buffer.reset();
				processing = false;
			}
		}
		
		//logger.info("Finishing Translate: " + result.size() + " messages translated.");
				
		return result;
	}