MAINT: optimize: update import style and simplify a couple variables swaps in optimize.py