Update to ensure template is after median time.

Also, convert to use new chain state.