Autofreeze support

Following #13 this is the full PR which also includes autofreeze support.