Removed unused variables and fixed types.
Modularized code and added compression functions