Refactor and compress