Cleaned up code and added the same fix to Canvas::StreamPngSync