https://gist.github.com/esc24/acdd2bda54c190cab298 updated to handle mixins/multiple inheritance.