Added pre-serialize and post-deserialize hooks