Fix deriving errors
Fix min/max type error