Add more detailed comments about the dynamic background and simplify some of the logic involved.