Speed up: RecordScreenAsGIF
Bug fix: add sleeping to avoid busy loop
Further optimization for RecordScreenAsGIF