add basic cofree implementation
code cleanup