Improve object decoding loop (fixes #6).