Calculate max stage number at reopen.

Closes #147.