Finished example with user defined type_index, improved doocs and refactored some of the functions