Add support for limiting message length.

Initial patch by Rui Abreu Ferreira, final patch by Aymeric Augustin.

Fix #28, #29.