Don't recalc the header hash every time
Optimize primality tests