Fix serialization annotation and minor modifications to improve code.