Implemented CAS

It compiles, but I haven't even tested it once. *fingers crossed*