refactor clisp, split into a general lib