Deriving the frame count and the beat alignment from one number is the detail most loop tools get wrong, and the drift only shows after a dozen repeats. The guards for a bad tempo estimate are worth having too. One thing I'd add: render at the frame rate the platform will actually play. If a platform re-encodes a 30 fps file to a different rate, the half frame you rounded away can come back at the seam.