Add initial cas

This adds the basic CAS. Not everything works yet, it's a work in progress.