Optimized unpack
Fixed encoding issues