The ByteReverse macro should probably be skipped before doing SHA-256 transforms.
before and after? theres several ByteReverse calls that probably need removal for the nonce ant the timestamp also.
in fact you may be able to do away completely with the temp block header thats mostly just there so it can be ByteReversed.