fixed wrong size of messages and signal handling