Attempt to fix #88, changing way how long messages handled

This is working version of the fix.