I've looked over it and can't see the problem. Short of having it on my system so I can test it piece by piece there not much more I can say.

I can only think of these possibilities.
1) your movement is being set somewhere else in the code also. Like a gravity function you haven't turned off.
2) your land function is being called more then once.
3) your not ignoring the me entity in the trace for floor distance IGNORE_ME, (but that might be why you use ignore_flags2)