Fixed several bugs in the mintime algorithm