Library: optimized unpack function