Prepare for optimization