bug fixes. fix big issue with instance state being saved.