Some minor improvements

A set of incremental improvements:
* make sure `optdone` is always a list
* make sure `optdone` is not set by default (added unit test for SP)
* other random minor changes