Pre and post generate reference

This fixes issue #26