Fix order decoding and other issues

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>