CS fix and by ref warning fixed