Fixed some bugs in argument passing, more clean-up of apply_ck