Added the multiple mint code, and tidied up the single mint code