Refactor render loop to wait for the last filesize