Implemented SDATA decompression algorithm.

Fixed SDATA debug mode handling and other small bugs.