Optimization-related fixes