fix encoding issues and limit packet size to 500