more captains fixes

- implemented 'ready' permission check correctly this time (only can be
done by the team captain)
- made most functions local and shuffled the order of functions to make
sure they are declared before use