fixed bug with timer length variable overflow and phase advancing