Some actual fixes and some pointless..
Rewrote minmax