Improved calculation for rhythm margin
Added an animation variable and compiled