Optimization: do not store zeros unnecessarily