Structure optimization (step 1)