[refactor] in optimizer, use mixin for handling stash