More work on optimizer