Code fixes, including fixing a bug in shared reference decoding