Finished compression function, still need to merge with Jesse's code