added min and other minor fixes