1. Improve serialize (avoding one string dup)
2. Fixed possible segfault(leave memleak now..it can't be fixed in a easy way)