Select the asset before calling optimize. Otherwise it will use the current selected asset. If none is selected because you just loaded a new asset list, the asset is undefined.