Code improvements for screen recording