Re-write everything. Use libsquish.