should be last changes for libcsp, code cleaned up, should work, going to check