Added box compression
Minor refactoring