If you address timing issues, please also have a look at how delay() is currently implemented. Unfortunately, it seems that many Arduino cores (if not all) are getting this wrong: they all use unsigned subtraction to compare time values. While that may seem mathematically correct, it's not...