add support for mixins, integrate flatten into semantic, and improve scheduler (both were needed for mixins)