Completed (almost certainly buggy) code in message entry method; no gross errors.