A more precise setInterval/setTimeout that avoids drifting