Multibyte Remaining Length

Added support for multibyte remaining length.
Moved more complex macros to functions.