Zero is false.  found by cppcheck
Check limit on 'i' before dereferencing it
Don't conflict with enum
Use "handshake_finished" instead of "finished"

To avoid polluting the global namespace with an enum