Fixed calculation of valid bit and adjusted delay as per @jlingema for #26.