adds minres
fixes small bugs and some comments