Optimalization and formatting