Fix min/max
Don't use unnecessary unsafe code.