Added C++ support. need to optimize some parts (e.g list->head can become a list straight through)