source from and created by https://bitbucket.org/khinsen/mmtk