Cleaned up examples. Using optim.