Do not encode unsupported types as undefined value, simplify error logging calls and fix crash on invalid input while decoding