Refactor compression logic in server