Make sure template refs are restored on wakeup

Fixes #176