Change maximum delay for state save from 2 secs to 5 secs.

Make timeout configurable at build time by defining SAVE_MAX_WAIT.