Fleshed out the CRF, added error handling