Just found a small bug in get_hitvertex.

After the c_trace, you must add 1 to the hitvertex operations to match the vertex numbering in MED. So change all lines like:

vec_for_uv(floor_vec,you,hitvertex);

for this:

vec_for_uv(floor_vec,you,hitvertex+1);

I think that only one line has to be changed (under MODEL detection).