parse UTF-16 surrogate pairs
fix memory leaks