refactor: added 2 more sync images for each reference frame refactor: optimized the code substantially