Refactor GIF animation code (untested with automatic start of animation when no one is playing)