Seems to work with 2 clients.

Moved stupid functions from main to common.c.