fixed some message length related bugs
fully working setup with no UI.