Added compress/save functions from @armadillu's original branch