constness fixes, round-trip and fuzz-testing for CHOICE
diff --git a/skeletons/ANY.c b/skeletons/ANY.c
index 396093f..b370f53 100644
--- a/skeletons/ANY.c
+++ b/skeletons/ANY.c
@@ -55,11 +55,10 @@
     } while(0)
 
 asn_enc_rval_t
-ANY_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-
-	if(flags & XER_F_CANONICAL) {
+ANY_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+               enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+               void *app_key) {
+    if(flags & XER_F_CANONICAL) {
 		/*
 		 * Canonical XER-encoding of ANY type is not supported.
 		 */
@@ -183,7 +182,8 @@
 #ifndef ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                const asn_TYPE_descriptor_t *td,
                 const asn_per_constraints_t *constraints, void **sptr,
                 asn_per_data_t *pd) {
     const asn_OCTET_STRING_specifics_t *specs =
@@ -240,8 +240,8 @@
 }
 
 asn_enc_rval_t
-ANY_encode_uper(asn_TYPE_descriptor_t *td,
-                const asn_per_constraints_t *constraints, void *sptr,
+ANY_encode_uper(const asn_TYPE_descriptor_t *td,
+                const asn_per_constraints_t *constraints, const void *sptr,
                 asn_per_outp_t *po) {
     const ANY_t *st = (const ANY_t *)sptr;
     asn_enc_rval_t er = {0, 0, 0};
diff --git a/skeletons/ANY.h b/skeletons/ANY.h
index 7d5f369..70d42a9 100644
--- a/skeletons/ANY.h
+++ b/skeletons/ANY.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef ASN_TYPE_ANY_H
diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c
index 69e7bc7..1a76f47 100644
--- a/skeletons/BIT_STRING.c
+++ b/skeletons/BIT_STRING.c
@@ -61,9 +61,9 @@
  * BIT STRING generic constraint.
  */
 int
-BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
+BIT_STRING_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 
 	if(st && st->buf) {
 		if((st->size == 0 && st->bits_unused)
@@ -89,10 +89,10 @@
 };
 
 asn_enc_rval_t
-BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t er;
+BIT_STRING_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      int ilevel, enum xer_encoder_flags_e flags,
+                      asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_enc_rval_t er;
 	char scratch[128];
 	char *p = scratch;
 	char *scend = scratch + (sizeof(scratch) - 10);
@@ -151,9 +151,9 @@
  * BIT STRING specific contents printer.
  */
 int
-BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const char * const h2c = "0123456789ABCDEF";
+BIT_STRING_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                 asn_app_consume_bytes_f *cb, void *app_key) {
+    const char * const h2c = "0123456789ABCDEF";
 	char scratch[64];
 	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 	uint8_t *buf;
@@ -316,9 +316,9 @@
 
 asn_dec_rval_t
 BIT_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-                         asn_TYPE_descriptor_t *td,
-                         const asn_per_constraints_t *constraints, void **sptr,
-                         asn_per_data_t *pd) {
+                       const asn_TYPE_descriptor_t *td,
+                       const asn_per_constraints_t *constraints, void **sptr,
+                       asn_per_data_t *pd) {
     const asn_OCTET_STRING_specifics_t *specs = td->specifics
 		? (const asn_OCTET_STRING_specifics_t *)td->specifics
 		: &asn_SPC_BIT_STRING_specs;
@@ -419,9 +419,9 @@
 }
 
 asn_enc_rval_t
-BIT_STRING_encode_uper(asn_TYPE_descriptor_t *td,
-                         const asn_per_constraints_t *constraints, void *sptr,
-                         asn_per_outp_t *po) {
+BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
+                       const asn_per_constraints_t *constraints,
+                       const void *sptr, asn_per_outp_t *po) {
     const asn_OCTET_STRING_specifics_t *specs =
         td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
                       : &asn_SPC_BIT_STRING_specs;
@@ -573,8 +573,7 @@
         0, sizeof(lengths) / sizeof(lengths[0]) - 1)];
     if(!constraints) constraints = &td->encoding_constraints;
     if(constraints->per_constraints) {
-        const asn_per_constraint_t *pc =
-            &td->encoding_constraints.per_constraints->size;
+        const asn_per_constraint_t *pc = &constraints->per_constraints->size;
         if(pc->flags & APC_CONSTRAINED) {
             long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length
                                              ? pc->upper_bound
diff --git a/skeletons/BIT_STRING.h b/skeletons/BIT_STRING.h
index ce3be19..bd2d23d 100644
--- a/skeletons/BIT_STRING.h
+++ b/skeletons/BIT_STRING.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BIT_STRING_H_
diff --git a/skeletons/BIT_STRING_oer.c b/skeletons/BIT_STRING_oer.c
index b18e27f..a5f289c 100644
--- a/skeletons/BIT_STRING_oer.c
+++ b/skeletons/BIT_STRING_oer.c
@@ -10,7 +10,8 @@
 #include <errno.h>
 
 asn_dec_rval_t
-BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                      const asn_TYPE_descriptor_t *td,
                       const asn_oer_constraints_t *constraints, void **sptr,
                       const void *ptr, size_t size) {
     BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
@@ -89,10 +90,11 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-BIT_STRING_encode_oer(asn_TYPE_descriptor_t *td,
-                        const asn_oer_constraints_t *constraints, void *sptr,
-                        asn_app_consume_bytes_f *cb, void *app_key) {
-    BIT_STRING_t *st = (BIT_STRING_t *)sptr;
+BIT_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
+                      const asn_oer_constraints_t *constraints,
+                      const void *sptr, asn_app_consume_bytes_f *cb,
+                      void *app_key) {
+    const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
     asn_enc_rval_t erval = {0, 0, 0};
     const asn_oer_constraints_t *cts =
         constraints ? constraints : td->encoding_constraints.oer_constraints;
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index 8fa583b..e9958ff 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -64,9 +64,8 @@
 };
 
 int
-BMPString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-                           asn_app_constraint_failed_f *ctfailcb,
-                           void *app_key) {
+BMPString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                     asn_app_constraint_failed_f *ctfailcb, void *app_key) {
     const BMPString_t *st = (const BMPString_t *)sptr;
 
     if(st && st->buf) {
@@ -128,9 +127,9 @@
 
 asn_dec_rval_t
 BMPString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-		const char *opt_mname, const void *buf_ptr, size_t size) {
-	asn_dec_rval_t rc;
+                     const asn_TYPE_descriptor_t *td, void **sptr,
+                     const char *opt_mname, const void *buf_ptr, size_t size) {
+    asn_dec_rval_t rc;
 
 	rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
 		buf_ptr, size);
@@ -193,10 +192,10 @@
 }
 
 asn_enc_rval_t
-BMPString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const BMPString_t *st = (const BMPString_t *)sptr;
+BMPString_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                     int ilevel, enum xer_encoder_flags_e flags,
+                     asn_app_consume_bytes_f *cb, void *app_key) {
+    const BMPString_t *st = (const BMPString_t *)sptr;
 	asn_enc_rval_t er;
 
 	(void)ilevel;
@@ -212,9 +211,9 @@
 }
 
 int
-BMPString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const BMPString_t *st = (const BMPString_t *)sptr;
+BMPString_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                asn_app_consume_bytes_f *cb, void *app_key) {
+    const BMPString_t *st = (const BMPString_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/BMPString.h b/skeletons/BMPString.h
index f465797..b3be163 100644
--- a/skeletons/BMPString.h
+++ b/skeletons/BMPString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BMPString_H_
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c
index 8102d04..3da5a6b 100644
--- a/skeletons/BOOLEAN.c
+++ b/skeletons/BOOLEAN.c
@@ -55,10 +55,9 @@
  */
 asn_dec_rval_t
 BOOLEAN_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
-		asn_TYPE_descriptor_t *td,
-		void **bool_value, const void *buf_ptr, size_t size,
-		int tag_mode) {
-	BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
+                   const asn_TYPE_descriptor_t *td, void **bool_value,
+                   const void *buf_ptr, size_t size, int tag_mode) {
+    BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
 	asn_dec_rval_t rval;
 	ber_tlv_len_t length;
 	ber_tlv_len_t lidx;
@@ -117,13 +116,13 @@
 }
 
 asn_enc_rval_t
-BOOLEAN_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t erval;
-	BOOLEAN_t *st = (BOOLEAN_t *)sptr;
+BOOLEAN_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
+                   void *app_key) {
+    asn_enc_rval_t erval;
+    const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
 
-	erval.encoded = der_write_tags(td, 1, tag_mode, 0, tag, cb, app_key);
+    erval.encoded = der_write_tags(td, 1, tag_mode, 0, tag, cb, app_key);
 	if(erval.encoded == -1) {
 		erval.failed_type = td;
 		erval.structure_ptr = sptr;
@@ -153,8 +152,9 @@
  * Decode the chunk of XML text encoding INTEGER.
  */
 static enum xer_pbd_rval
-BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	BOOLEAN_t *st = (BOOLEAN_t *)sptr;
+BOOLEAN__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                         const void *chunk_buf, size_t chunk_size) {
+    BOOLEAN_t *st = (BOOLEAN_t *)sptr;
 	const char *p = (const char *)chunk_buf;
 
 	(void)td;
@@ -184,16 +184,15 @@
 
 asn_dec_rval_t
 BOOLEAN_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                   const asn_TYPE_descriptor_t *td, void **sptr,
+                   const char *opt_mname, const void *buf_ptr, size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(BOOLEAN_t), opt_mname, buf_ptr, size,
 		BOOLEAN__xer_body_decode);
 }
 
 asn_enc_rval_t
-BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
+BOOLEAN_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
 	int ilevel, enum xer_encoder_flags_e flags,
 		asn_app_consume_bytes_f *cb, void *app_key) {
 	const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
@@ -216,9 +215,9 @@
 }
 
 int
-BOOLEAN_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
+BOOLEAN_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+              asn_app_consume_bytes_f *cb, void *app_key) {
+    const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
 	const char *buf;
 	size_t buflen;
 
@@ -261,7 +260,8 @@
 #ifndef ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-BOOLEAN_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+BOOLEAN_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                    const asn_TYPE_descriptor_t *td,
                     const asn_per_constraints_t *constraints, void **sptr,
                     asn_per_data_t *pd) {
     asn_dec_rval_t rv;
@@ -294,8 +294,8 @@
 
 
 asn_enc_rval_t
-BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
-                    const asn_per_constraints_t *constraints, void *sptr,
+BOOLEAN_encode_uper(const asn_TYPE_descriptor_t *td,
+                    const asn_per_constraints_t *constraints, const void *sptr,
                     asn_per_outp_t *po) {
     const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
 	asn_enc_rval_t er = { 0, 0, 0 };
@@ -318,8 +318,8 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-BOOLEAN_encode_oer(asn_TYPE_descriptor_t *td,
-                   const asn_oer_constraints_t *constraints, void *sptr,
+BOOLEAN_encode_oer(const asn_TYPE_descriptor_t *td,
+                   const asn_oer_constraints_t *constraints, const void *sptr,
                    asn_app_consume_bytes_f *cb, void *app_key) {
     asn_enc_rval_t er = { 1, 0, 0 };
     const BOOLEAN_t *st = sptr;
@@ -337,9 +337,9 @@
 
 asn_dec_rval_t
 BOOLEAN_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                        asn_TYPE_descriptor_t *td,
-                        const asn_oer_constraints_t *constraints, void **sptr,
-                        const void *ptr, size_t size) {
+                   const asn_TYPE_descriptor_t *td,
+                   const asn_oer_constraints_t *constraints, void **sptr,
+                   const void *ptr, size_t size) {
     asn_dec_rval_t ok = {RC_OK, 1};
     BOOLEAN_t *st;
 
diff --git a/skeletons/BOOLEAN.h b/skeletons/BOOLEAN.h
index bdf6ce0..7e6b8fb 100644
--- a/skeletons/BOOLEAN.h
+++ b/skeletons/BOOLEAN.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BOOLEAN_H_
diff --git a/skeletons/ENUMERATED.c b/skeletons/ENUMERATED.c
index b4134bb..c5c197e 100644
--- a/skeletons/ENUMERATED.c
+++ b/skeletons/ENUMERATED.c
@@ -57,7 +57,7 @@
 
 asn_dec_rval_t
 ENUMERATED_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                      asn_TYPE_descriptor_t *td,
+                      const asn_TYPE_descriptor_t *td,
                       const asn_oer_constraints_t *constraints, void **sptr,
                       const void *ptr, size_t size) {
     asn_dec_rval_t rval;
@@ -81,10 +81,11 @@
 }
 
 asn_enc_rval_t
-ENUMERATED_encode_oer(asn_TYPE_descriptor_t *td,
-                      const asn_oer_constraints_t *constraints, void *sptr,
-                      asn_app_consume_bytes_f *cb, void *app_key) {
-    ENUMERATED_t *st = (ENUMERATED_t *)sptr;
+ENUMERATED_encode_oer(const asn_TYPE_descriptor_t *td,
+                      const asn_oer_constraints_t *constraints,
+                      const void *sptr, asn_app_consume_bytes_f *cb,
+                      void *app_key) {
+    const ENUMERATED_t *st = sptr;
 	long value;
 
 	if(asn_INTEGER2long(st, &value)) {
@@ -100,7 +101,7 @@
 
 asn_dec_rval_t
 ENUMERATED_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-                       asn_TYPE_descriptor_t *td,
+                       const asn_TYPE_descriptor_t *td,
                        const asn_per_constraints_t *constraints, void **sptr,
                        asn_per_data_t *pd) {
     asn_dec_rval_t rval;
@@ -124,10 +125,10 @@
 }
 
 asn_enc_rval_t
-ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td,
-                       const asn_per_constraints_t *constraints, void *sptr,
-                       asn_per_outp_t *po) {
-    ENUMERATED_t *st = (ENUMERATED_t *)sptr;
+ENUMERATED_encode_uper(const asn_TYPE_descriptor_t *td,
+                       const asn_per_constraints_t *constraints,
+                       const void *sptr, asn_per_outp_t *po) {
+    const ENUMERATED_t *st = (const ENUMERATED_t *)sptr;
     long value;
 
     if(asn_INTEGER2long(st, &value)) {
diff --git a/skeletons/ENUMERATED.h b/skeletons/ENUMERATED.h
index 14ed8bb..5bb6a2e 100644
--- a/skeletons/ENUMERATED.h
+++ b/skeletons/ENUMERATED.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_ENUMERATED_H_
diff --git a/skeletons/GeneralString.h b/skeletons/GeneralString.h
index 55b994f..074c364 100644
--- a/skeletons/GeneralString.h
+++ b/skeletons/GeneralString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_GeneralString_H_
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 365ef19..b2d0603 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -219,9 +219,10 @@
  * Check that the time looks like the time.
  */
 int
-GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
+GeneralizedTime_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                           asn_app_constraint_failed_f *ctfailcb,
+                           void *app_key) {
+    const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
 	time_t tloc;
 
 	errno = EPERM;			/* Just an unlikely error code */
@@ -237,10 +238,10 @@
 }
 
 asn_enc_rval_t
-GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	GeneralizedTime_t *st = (GeneralizedTime_t *)sptr;
+GeneralizedTime_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                           int tag_mode, ber_tlv_tag_t tag,
+                           asn_app_consume_bytes_f *cb, void *app_key) {
+    GeneralizedTime_t *st;
 	asn_enc_rval_t erval;
 	int fv, fd;	/* seconds fraction value and number of digits */
 	struct tm tm;
@@ -249,38 +250,38 @@
 	/*
 	 * Encode as a canonical DER.
 	 */
-	errno = EPERM;
-	tloc = asn_GT2time_frac(st, &fv, &fd, &tm, 1);	/* Recognize time */
-	if(tloc == -1 && errno != EPERM)
-		/* Failed to recognize time. Fail completely. */
+    errno = EPERM;
+    tloc = asn_GT2time_frac((const GeneralizedTime_t *)sptr, &fv, &fd, &tm,
+                            1); /* Recognize time */
+    if(tloc == -1 && errno != EPERM) {
+        /* Failed to recognize time. Fail completely. */
 		ASN__ENCODE_FAILED;
+    }
 
-	st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */
-	if(!st) ASN__ENCODE_FAILED;	/* Memory allocation failure. */
+    st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */
+    if(!st) ASN__ENCODE_FAILED;               /* Memory allocation failure. */
 
-	erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key);
+    erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key);
 
-	FREEMEM(st->buf);
-	FREEMEM(st);
+    ASN_STRUCT_FREE(*td, st);
 
-	return erval;
+    return erval;
 }
 
 #ifndef	ASN___INTERNAL_TEST_MODE
 
 asn_enc_rval_t
-GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-
-	if(flags & XER_F_CANONICAL) {
+GeneralizedTime_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                           int ilevel, enum xer_encoder_flags_e flags,
+                           asn_app_consume_bytes_f *cb, void *app_key) {
+    if(flags & XER_F_CANONICAL) {
 		GeneralizedTime_t *gt;
 		asn_enc_rval_t rv;
 		int fv, fd;		/* fractional parts */
 		struct tm tm;
 
 		errno = EPERM;
-		if(asn_GT2time_frac((GeneralizedTime_t *)sptr,
+		if(asn_GT2time_frac((const GeneralizedTime_t *)sptr,
 					&fv, &fd, &tm, 1) == -1
 				&& errno != EPERM)
 			ASN__ENCODE_FAILED;
@@ -301,9 +302,9 @@
 #endif	/* ASN___INTERNAL_TEST_MODE */
 
 int
-GeneralizedTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
+GeneralizedTime_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+    const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/GeneralizedTime.h b/skeletons/GeneralizedTime.h
index 92f0029..c4e5c56 100644
--- a/skeletons/GeneralizedTime.h
+++ b/skeletons/GeneralizedTime.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_GeneralizedTime_H_
diff --git a/skeletons/GraphicString.h b/skeletons/GraphicString.h
index 420521d..82b1929 100644
--- a/skeletons/GraphicString.h
+++ b/skeletons/GraphicString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_GraphicString_H_
diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c
index 6530ba3..4397041 100644
--- a/skeletons/IA5String.c
+++ b/skeletons/IA5String.c
@@ -58,9 +58,9 @@
 };
 
 int
-IA5String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const IA5String_t *st = (const IA5String_t *)sptr;
+IA5String_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                     asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const IA5String_t *st = (const IA5String_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/IA5String.h b/skeletons/IA5String.h
index fa9f7ac..5a4d5f2 100644
--- a/skeletons/IA5String.h
+++ b/skeletons/IA5String.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_IA5String_H_
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index 3257cf7..b1103ad 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -56,10 +56,12 @@
  * Encode INTEGER type using DER.
  */
 asn_enc_rval_t
-INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	INTEGER_t *st = (INTEGER_t *)sptr;
+INTEGER_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
+                   void *app_key) {
+    const INTEGER_t *st = (const INTEGER_t *)sptr;
+    asn_enc_rval_t rval;
+    INTEGER_t effective_integer;
 
 	ASN_DEBUG("%s %s as INTEGER (tm=%d)",
 		cb?"Encoding":"Estimating", td->name, tag_mode);
@@ -96,19 +98,23 @@
 		/* Remove leading superfluous bytes from the integer */
 		shift = buf - st->buf;
 		if(shift) {
-			uint8_t *nb = st->buf;
-			uint8_t *end;
+            union {
+                const uint8_t *c_buf;
+                uint8_t *nc_buf;
+            } unconst;
+            unconst.c_buf = st->buf;
+            effective_integer.buf = unconst.nc_buf + shift;
+            effective_integer.size = st->size - shift;
 
-			st->size -= shift;	/* New size, minus bad bytes */
-			end = nb + st->size;
+            st = &effective_integer;
+        }
+    }
 
-			for(; nb < end; nb++, buf++)
-				*nb = *buf;
-		}
-
-	} /* if(1) */
-
-	return der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key);
+	rval = der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key);
+    if(rval.structure_ptr == &effective_integer) {
+        rval.structure_ptr = sptr;
+    }
+    return rval;
 }
 
 static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(
@@ -194,12 +200,11 @@
  * INTEGER specific human-readable output.
  */
 int
-INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const INTEGER_t *st = (const INTEGER_t *)sptr;
+INTEGER_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+              asn_app_consume_bytes_f *cb, void *app_key) {
+    const INTEGER_t *st = (const INTEGER_t *)sptr;
 	ssize_t ret;
 
-	(void)td;
 	(void)ilevel;
 
 	if(!st || !st->buf)
@@ -311,8 +316,9 @@
  * Decode the chunk of XML text encoding INTEGER.
  */
 static enum xer_pbd_rval
-INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	INTEGER_t *st = (INTEGER_t *)sptr;
+INTEGER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                         const void *chunk_buf, size_t chunk_size) {
+    INTEGER_t *st = (INTEGER_t *)sptr;
 	intmax_t dec_value;
 	intmax_t hex_value = 0;
 	const char *lp;
@@ -543,19 +549,18 @@
 
 asn_dec_rval_t
 INTEGER_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                   const asn_TYPE_descriptor_t *td, void **sptr,
+                   const char *opt_mname, const void *buf_ptr, size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(INTEGER_t), opt_mname,
 		buf_ptr, size, INTEGER__xer_body_decode);
 }
 
 asn_enc_rval_t
-INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const INTEGER_t *st = (const INTEGER_t *)sptr;
+INTEGER_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int ilevel, enum xer_encoder_flags_e flags,
+                   asn_app_consume_bytes_f *cb, void *app_key) {
+    const INTEGER_t *st = (const INTEGER_t *)sptr;
 	asn_enc_rval_t er;
 
 	(void)ilevel;
@@ -573,7 +578,8 @@
 #ifndef	ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                    const asn_TYPE_descriptor_t *td,
                     const asn_per_constraints_t *constraints, void **sptr,
                     asn_per_data_t *pd) {
     const asn_INTEGER_specifics_t *specs =
@@ -689,13 +695,13 @@
 }
 
 asn_enc_rval_t
-INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
-                    const asn_per_constraints_t *constraints, void *sptr,
+INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
+                    const asn_per_constraints_t *constraints, const void *sptr,
                     asn_per_outp_t *po) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     asn_enc_rval_t er;
-	INTEGER_t *st = (INTEGER_t *)sptr;
+	const INTEGER_t *st = (const INTEGER_t *)sptr;
 	const uint8_t *buf;
 	const uint8_t *end;
 	const asn_per_constraint_t *ct;
diff --git a/skeletons/INTEGER.h b/skeletons/INTEGER.h
index 708d845..8efd75c 100644
--- a/skeletons/INTEGER.h
+++ b/skeletons/INTEGER.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_INTEGER_H_
diff --git a/skeletons/INTEGER_oer.c b/skeletons/INTEGER_oer.c
index bea2e07..5c98d3e 100644
--- a/skeletons/INTEGER_oer.c
+++ b/skeletons/INTEGER_oer.c
@@ -10,7 +10,8 @@
 #include <errno.h>
 
 asn_dec_rval_t
-INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                   const asn_TYPE_descriptor_t *td,
                    const asn_oer_constraints_t *constraints, void **sptr,
                    const void *ptr, size_t size) {
     const asn_INTEGER_specifics_t *specs =
@@ -99,8 +100,8 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-INTEGER_encode_oer(asn_TYPE_descriptor_t *td,
-                   const asn_oer_constraints_t *constraints, void *sptr,
+INTEGER_encode_oer(const asn_TYPE_descriptor_t *td,
+                   const asn_oer_constraints_t *constraints, const void *sptr,
                    asn_app_consume_bytes_f *cb, void *app_key) {
     const INTEGER_t *st = sptr;
     asn_enc_rval_t er;
diff --git a/skeletons/ISO646String.h b/skeletons/ISO646String.h
index 4948315..dcaa414 100644
--- a/skeletons/ISO646String.h
+++ b/skeletons/ISO646String.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_ISO646String_H_
diff --git a/skeletons/Makefile.am b/skeletons/Makefile.am
index 43fde66..698e4bb 100644
--- a/skeletons/Makefile.am
+++ b/skeletons/Makefile.am
@@ -50,7 +50,7 @@
     OBJECT_IDENTIFIER.c OBJECT_IDENTIFIER.h     \
     OCTET_STRING.c OCTET_STRING.h               \
     OCTET_STRING_oer.c                          \
-    OPEN_TYPE.c OPEN_TYPE.h                     \
+    OPEN_TYPE.c OPEN_TYPE.h OPEN_TYPE_oer.c     \
     ObjectDescriptor.c ObjectDescriptor.h       \
     PrintableString.c PrintableString.h         \
     REAL.c REAL.h                               \
diff --git a/skeletons/NULL.c b/skeletons/NULL.c
index ed7f853..77a377e 100644
--- a/skeletons/NULL.c
+++ b/skeletons/NULL.c
@@ -52,10 +52,9 @@
 };
 
 asn_enc_rval_t
-NULL_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t erval;
+NULL_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode,
+                ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_enc_rval_t erval;
 
 	erval.encoded = der_write_tags(td, 0, tag_mode, 0, tag, cb, app_key);
 	if(erval.encoded == -1) {
@@ -67,10 +66,10 @@
 }
 
 asn_enc_rval_t
-NULL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t er;
+NULL_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+                void *app_key) {
+    asn_enc_rval_t er;
 
 	(void)td;
 	(void)sptr;
@@ -86,8 +85,9 @@
 
 
 static enum xer_pbd_rval
-NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	(void)td;
+NULL__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                      const void *chunk_buf, size_t chunk_size) {
+    (void)td;
 	(void)sptr;
 	(void)chunk_buf;    /* Going to be empty according to the rules below. */
 
@@ -102,10 +102,9 @@
 
 asn_dec_rval_t
 NULL_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                const asn_TYPE_descriptor_t *td, void **sptr,
+                const char *opt_mname, const void *buf_ptr, size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(NULL_t), opt_mname, buf_ptr, size,
 		NULL__xer_body_decode);
 }
@@ -119,10 +118,9 @@
 }
 
 int
-NULL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-
-	(void)td;	/* Unused argument */
+NULL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+           asn_app_consume_bytes_f *cb, void *app_key) {
+    (void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
 
 	if(sptr) {
@@ -135,9 +133,10 @@
 #ifndef ASN_DISABLE_OER_SUPPORT
 
 asn_dec_rval_t
-NULL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-                  const asn_oer_constraints_t *constraints, void **struct_ptr,
-                  const void *ptr, size_t size) {
+NULL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                const asn_TYPE_descriptor_t *td,
+                const asn_oer_constraints_t *constraints, void **struct_ptr,
+                const void *ptr, size_t size) {
     asn_dec_rval_t rv = {RC_OK, 0};
     (void)opt_codec_ctx;
     (void)td;
@@ -149,8 +148,8 @@
 }
 
 asn_enc_rval_t
-NULL_encode_oer(asn_TYPE_descriptor_t *td,
-                const asn_oer_constraints_t *constraints, void *sptr,
+NULL_encode_oer(const asn_TYPE_descriptor_t *td,
+                const asn_oer_constraints_t *constraints, const void *sptr,
                 asn_app_consume_bytes_f *cb, void *app_key) {
     asn_enc_rval_t er;
 
@@ -170,7 +169,8 @@
 #ifndef ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-NULL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+NULL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                 const asn_TYPE_descriptor_t *td,
                  const asn_per_constraints_t *constraints, void **sptr,
                  asn_per_data_t *pd) {
     asn_dec_rval_t rv;
@@ -199,8 +199,8 @@
 }
 
 asn_enc_rval_t
-NULL_encode_uper(asn_TYPE_descriptor_t *td,
-                 const asn_per_constraints_t *constraints, void *sptr,
+NULL_encode_uper(const asn_TYPE_descriptor_t *td,
+                 const asn_per_constraints_t *constraints, const void *sptr,
                  asn_per_outp_t *po) {
     asn_enc_rval_t er;
 
diff --git a/skeletons/NULL.h b/skeletons/NULL.h
index 050840a..50f53ca 100644
--- a/skeletons/NULL.h
+++ b/skeletons/NULL.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_TYPE_NULL_H
diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c
index d95dea2..4ed8749 100644
--- a/skeletons/NativeEnumerated.c
+++ b/skeletons/NativeEnumerated.c
@@ -57,8 +57,8 @@
 };
 
 asn_enc_rval_t
-NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
-                            enum xer_encoder_flags_e flags,
+NativeEnumerated_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                            int ilevel, enum xer_encoder_flags_e flags,
                             asn_app_consume_bytes_f *cb, void *app_key) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
@@ -87,10 +87,10 @@
 
 asn_dec_rval_t
 NativeEnumerated_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints,
-	void **sptr, asn_per_data_t *pd) {
-    const asn_INTEGER_specifics_t *specs =
-        (const asn_INTEGER_specifics_t *)td->specifics;
+                             const asn_TYPE_descriptor_t *td,
+                             const asn_per_constraints_t *constraints,
+                             void **sptr, asn_per_data_t *pd) {
+    const asn_INTEGER_specifics_t *specs = td->specifics;
     asn_dec_rval_t rval = { RC_OK, 0 };
 	long *native = (long *)*sptr;
 	const asn_per_constraint_t *ct;
@@ -154,9 +154,9 @@
 }
 
 asn_enc_rval_t
-NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
+NativeEnumerated_encode_uper(const asn_TYPE_descriptor_t *td,
                              const asn_per_constraints_t *constraints,
-                             void *sptr, asn_per_outp_t *po) {
+                             const void *sptr, asn_per_outp_t *po) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     asn_enc_rval_t er;
@@ -178,7 +178,7 @@
 
 	er.encoded = 0;
 
-	native = *(long *)sptr;
+	native = *(const long *)sptr;
 
 	key.nat_value = native;
 	kf = bsearch(&key, specs->value2enum, specs->map_count,
diff --git a/skeletons/NativeEnumerated.h b/skeletons/NativeEnumerated.h
index dc4e323..4d897a0 100644
--- a/skeletons/NativeEnumerated.h
+++ b/skeletons/NativeEnumerated.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+/*
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
diff --git a/skeletons/NativeEnumerated_oer.c b/skeletons/NativeEnumerated_oer.c
index 9b0c0d3..3222348 100644
--- a/skeletons/NativeEnumerated_oer.c
+++ b/skeletons/NativeEnumerated_oer.c
@@ -31,7 +31,7 @@
 
 asn_dec_rval_t
 NativeEnumerated_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                            asn_TYPE_descriptor_t *td,
+                            const asn_TYPE_descriptor_t *td,
                             const asn_oer_constraints_t *constraints,
                             void **nint_ptr, const void *ptr, size_t size) {
     asn_dec_rval_t rval = {RC_OK, 0};
@@ -99,9 +99,9 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-NativeEnumerated_encode_oer(asn_TYPE_descriptor_t *td,
+NativeEnumerated_encode_oer(const asn_TYPE_descriptor_t *td,
                             const asn_oer_constraints_t *constraints,
-                            void *sptr, asn_app_consume_bytes_f *cb,
+                            const void *sptr, asn_app_consume_bytes_f *cb,
                             void *app_key) {
     asn_enc_rval_t er;
     long native;
diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c
index 05ecae0..f172437 100644
--- a/skeletons/NativeInteger.c
+++ b/skeletons/NativeInteger.c
@@ -62,8 +62,8 @@
  */
 asn_dec_rval_t
 NativeInteger_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td,
-	void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) {
+                         const asn_TYPE_descriptor_t *td, void **nint_ptr,
+                         const void *buf_ptr, size_t size, int tag_mode) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     long *native = (long *)*nint_ptr;
@@ -147,11 +147,11 @@
  * Encode the NativeInteger using the standard INTEGER type DER encoder.
  */
 asn_enc_rval_t
-NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	unsigned long native = *(unsigned long *)ptr;	/* Disable sign ext. */
-	asn_enc_rval_t erval;
+NativeInteger_encode_der(const asn_TYPE_descriptor_t *sd, const void *ptr,
+                         int tag_mode, ber_tlv_tag_t tag,
+                         asn_app_consume_bytes_f *cb, void *app_key) {
+    unsigned long native = *(const unsigned long *)ptr; /* Disable sign ext. */
+    asn_enc_rval_t erval;
 	INTEGER_t tmp;
 
 #ifdef	WORDS_BIGENDIAN		/* Opportunistic optimization */
@@ -173,10 +173,9 @@
 	
 	/* Encode fake INTEGER */
 	erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key);
-	if(erval.encoded == -1) {
-		assert(erval.structure_ptr == &tmp);
-		erval.structure_ptr = ptr;
-	}
+    if(erval.structure_ptr == &tmp) {
+        erval.structure_ptr = ptr;
+    }
 	return erval;
 }
 
@@ -185,8 +184,9 @@
  */
 asn_dec_rval_t
 NativeInteger_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
+                         const asn_TYPE_descriptor_t *td, void **sptr,
+                         const char *opt_mname, const void *buf_ptr,
+                         size_t size) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     asn_dec_rval_t rval;
@@ -226,9 +226,9 @@
 
 
 asn_enc_rval_t
-NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
+NativeInteger_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                         int ilevel, enum xer_encoder_flags_e flags,
+                         asn_app_consume_bytes_f *cb, void *app_key) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     char scratch[32];	/* Enough for 64-bit int */
@@ -254,7 +254,7 @@
 
 asn_dec_rval_t
 NativeInteger_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-                          asn_TYPE_descriptor_t *td,
+                          const asn_TYPE_descriptor_t *td,
                           const asn_per_constraints_t *constraints, void **sptr,
                           asn_per_data_t *pd) {
     const asn_INTEGER_specifics_t *specs =
@@ -290,9 +290,9 @@
 }
 
 asn_enc_rval_t
-NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
-                          const asn_per_constraints_t *constraints, void *sptr,
-                          asn_per_outp_t *po) {
+NativeInteger_encode_uper(const asn_TYPE_descriptor_t *td,
+                          const asn_per_constraints_t *constraints,
+                          const void *sptr, asn_per_outp_t *po) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     asn_enc_rval_t er;
@@ -301,9 +301,9 @@
 
 	if(!sptr) ASN__ENCODE_FAILED;
 
-	native = *(long *)sptr;
+    native = *(const long *)sptr;
 
-	ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
+    ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
 
 	memset(&tmpint, 0, sizeof(tmpint));
 	if((specs&&specs->field_unsigned)
@@ -321,8 +321,8 @@
  * INTEGER specific human-readable output.
  */
 int
-NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-                    asn_app_consume_bytes_f *cb, void *app_key) {
+NativeInteger_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                    int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     const long *native = (const long *)sptr;
diff --git a/skeletons/NativeInteger.h b/skeletons/NativeInteger.h
index 17a6486..e2741c2 100644
--- a/skeletons/NativeInteger.h
+++ b/skeletons/NativeInteger.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
diff --git a/skeletons/NativeInteger_oer.c b/skeletons/NativeInteger_oer.c
index f13f782..411413a 100644
--- a/skeletons/NativeInteger_oer.c
+++ b/skeletons/NativeInteger_oer.c
@@ -11,7 +11,7 @@
 
 asn_dec_rval_t
 NativeInteger_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                         asn_TYPE_descriptor_t *td,
+                         const asn_TYPE_descriptor_t *td,
                          const asn_oer_constraints_t *constraints,
                          void **nint_ptr, const void *ptr, size_t size) {
     const asn_INTEGER_specifics_t *specs =
@@ -68,9 +68,10 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-NativeInteger_encode_oer(asn_TYPE_descriptor_t *td,
-                         const asn_oer_constraints_t *constraints, void *sptr,
-                         asn_app_consume_bytes_f *cb, void *app_key) {
+NativeInteger_encode_oer(const asn_TYPE_descriptor_t *td,
+                         const asn_oer_constraints_t *constraints,
+                         const void *sptr, asn_app_consume_bytes_f *cb,
+                         void *app_key) {
     const asn_INTEGER_specifics_t *specs =
         (const asn_INTEGER_specifics_t *)td->specifics;
     INTEGER_t tmpint;
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index 382ef3b..f7bccd4 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -91,7 +91,7 @@
  */
 asn_dec_rval_t
 NativeReal_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
-                      asn_TYPE_descriptor_t *td, void **sptr,
+                      const asn_TYPE_descriptor_t *td, void **sptr,
                       const void *buf_ptr, size_t size, int tag_mode) {
     asn_dec_rval_t rval;
     ber_tlv_len_t length;
@@ -172,9 +172,9 @@
  * Encode the NativeReal using the standard REAL type DER encoder.
  */
 asn_enc_rval_t
-NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
+NativeReal_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      int tag_mode, ber_tlv_tag_t tag,
+                      asn_app_consume_bytes_f *cb, void *app_key) {
     double d = NativeReal__get_double(td, sptr);
     asn_enc_rval_t erval;
 	REAL_t tmp;
@@ -205,10 +205,10 @@
  */
 asn_dec_rval_t
 NativeReal_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-                       asn_TYPE_descriptor_t *td,
+                       const asn_TYPE_descriptor_t *td,
                        const asn_per_constraints_t *constraints, void **sptr,
                        asn_per_data_t *pd) {
-	asn_dec_rval_t rval;
+    asn_dec_rval_t rval;
     double d;
 	REAL_t tmp;
 	void *ptmp = &tmp;
@@ -238,9 +238,9 @@
  * Encode the NativeReal using the OCTET STRING PER encoder.
  */
 asn_enc_rval_t
-NativeReal_encode_uper(asn_TYPE_descriptor_t *td,
-                       const asn_per_constraints_t *constraints, void *sptr,
-                       asn_per_outp_t *po) {
+NativeReal_encode_uper(const asn_TYPE_descriptor_t *td,
+                       const asn_per_constraints_t *constraints,
+                       const void *sptr, asn_per_outp_t *po) {
     double d = NativeReal__get_double(td, sptr);
 	asn_enc_rval_t erval;
 	REAL_t tmp;
@@ -272,9 +272,10 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-NativeReal_encode_oer(asn_TYPE_descriptor_t *td,
-                   const asn_oer_constraints_t *constraints, void *sptr,
-                   asn_app_consume_bytes_f *cb, void *app_key) {
+NativeReal_encode_oer(const asn_TYPE_descriptor_t *td,
+                      const asn_oer_constraints_t *constraints,
+                      const void *sptr, asn_app_consume_bytes_f *cb,
+                      void *app_key) {
     asn_enc_rval_t er = {0, 0, 0};
 
     if(!constraints) constraints = td->encoding_constraints.oer_constraints;
@@ -335,9 +336,9 @@
 
 asn_dec_rval_t
 NativeReal_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                        asn_TYPE_descriptor_t *td,
-                        const asn_oer_constraints_t *constraints, void **sptr,
-                        const void *ptr, size_t size) {
+                      const asn_TYPE_descriptor_t *td,
+                      const asn_oer_constraints_t *constraints, void **sptr,
+                      const void *ptr, size_t size) {
     asn_dec_rval_t ok = {RC_OK, 0};
     double d;
     ssize_t len_len;
@@ -429,9 +430,9 @@
  */
 asn_dec_rval_t
 NativeReal_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-	asn_dec_rval_t rval;
+                      const asn_TYPE_descriptor_t *td, void **sptr,
+                      const char *opt_mname, const void *buf_ptr, size_t size) {
+    asn_dec_rval_t rval;
 	REAL_t st = { 0, 0 };
 	REAL_t *stp = &st;
 
@@ -452,9 +453,9 @@
 }
 
 asn_enc_rval_t
-NativeReal_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
+NativeReal_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      int ilevel, enum xer_encoder_flags_e flags,
+                      asn_app_consume_bytes_f *cb, void *app_key) {
     double d = NativeReal__get_double(td, sptr);
 	asn_enc_rval_t er;
 
@@ -470,10 +471,9 @@
  * REAL specific human-readable output.
  */
 int
-NativeReal_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-
-	(void)ilevel;	/* Unused argument */
+NativeReal_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                 asn_app_consume_bytes_f *cb, void *app_key) {
+    (void)ilevel;	/* Unused argument */
 
 	if(sptr) {
         double d = NativeReal__get_double(td, sptr);
diff --git a/skeletons/NativeReal.h b/skeletons/NativeReal.h
index c3e9e2d..b6d16d6 100644
--- a/skeletons/NativeReal.h
+++ b/skeletons/NativeReal.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c
index 891e4f5..c89597e 100644
--- a/skeletons/NumericString.c
+++ b/skeletons/NumericString.c
@@ -78,9 +78,9 @@
 };
 
 int
-NumericString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const NumericString_t *st = (const NumericString_t *)sptr;
+NumericString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const NumericString_t *st = (const NumericString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/NumericString.h b/skeletons/NumericString.h
index 8e4f7ec..ae79873 100644
--- a/skeletons/NumericString.h
+++ b/skeletons/NumericString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_NumericString_H_
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index 3f26477..290545d 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -56,9 +56,10 @@
 };
 
 int
-OBJECT_IDENTIFIER_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
+OBJECT_IDENTIFIER_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                             asn_app_constraint_failed_f *ctfailcb,
+                             void *app_key) {
+    const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 
 	if(st && st->buf) {
 		if(st->size < 1) {
@@ -182,8 +183,9 @@
 }
 
 static enum xer_pbd_rval
-OBJECT_IDENTIFIER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)sptr;
+OBJECT_IDENTIFIER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                                   const void *chunk_buf, size_t chunk_size) {
+    OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)sptr;
 	const char *chunk_end = (const char *)chunk_buf + chunk_size;
 	const char *endptr;
 	asn_oid_arc_t s_arcs[10];
@@ -224,19 +226,19 @@
 
 asn_dec_rval_t
 OBJECT_IDENTIFIER_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                             const asn_TYPE_descriptor_t *td, void **sptr,
+                             const char *opt_mname, const void *buf_ptr,
+                             size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(OBJECT_IDENTIFIER_t), opt_mname,
 			buf_ptr, size, OBJECT_IDENTIFIER__xer_body_decode);
 }
 
 asn_enc_rval_t
-OBJECT_IDENTIFIER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
+OBJECT_IDENTIFIER_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                             int ilevel, enum xer_encoder_flags_e flags,
+                             asn_app_consume_bytes_f *cb, void *app_key) {
+    const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 	asn_enc_rval_t er;
 
     (void)ilevel;
@@ -253,9 +255,10 @@
 }
 
 int
-OBJECT_IDENTIFIER_print(asn_TYPE_descriptor_t *td, const void *sptr,
-	int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
-	const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
+OBJECT_IDENTIFIER_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                        int ilevel, asn_app_consume_bytes_f *cb,
+                        void *app_key) {
+    const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/OBJECT_IDENTIFIER.h b/skeletons/OBJECT_IDENTIFIER.h
index 7336285..aa0d5c7 100644
--- a/skeletons/OBJECT_IDENTIFIER.h
+++ b/skeletons/OBJECT_IDENTIFIER.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
- * 	All rights reserved.
+/*
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_OBJECT_IDENTIFIER_H_
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index e618609..3946206 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -178,9 +178,9 @@
  */
 asn_dec_rval_t
 OCTET_STRING_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td,
-	void **sptr, const void *buf_ptr, size_t size, int tag_mode) {
-	const asn_OCTET_STRING_specifics_t *specs = td->specifics
+                        const asn_TYPE_descriptor_t *td, void **sptr,
+                        const void *buf_ptr, size_t size, int tag_mode) {
+    const asn_OCTET_STRING_specifics_t *specs = td->specifics
 				? (const asn_OCTET_STRING_specifics_t *)td->specifics
 				: &asn_SPC_OCTET_STRING_specs;
 	BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
@@ -532,14 +532,14 @@
  * Encode OCTET STRING type using DER.
  */
 asn_enc_rval_t
-OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t er;
+OCTET_STRING_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                        int tag_mode, ber_tlv_tag_t tag,
+                        asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_enc_rval_t er;
 	const asn_OCTET_STRING_specifics_t *specs = td->specifics
 				? (const asn_OCTET_STRING_specifics_t *)td->specifics
 				: &asn_SPC_OCTET_STRING_specs;
-	BIT_STRING_t *st = (BIT_STRING_t *)sptr;
+	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 	enum asn_OS_Subvariant type_variant = specs->subvariant;
 	int fix_last_byte = 0;
 
@@ -594,10 +594,10 @@
 }
 
 asn_enc_rval_t
-OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const char * const h2c = "0123456789ABCDEF";
+OCTET_STRING_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                        int ilevel, enum xer_encoder_flags_e flags,
+                        asn_app_consume_bytes_f *cb, void *app_key) {
+    const char * const h2c = "0123456789ABCDEF";
 	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 	asn_enc_rval_t er;
 	char scratch[16 * 3 + 4];
@@ -746,10 +746,10 @@
 }
 
 asn_enc_rval_t
-OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
+OCTET_STRING_encode_xer_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
+                             int ilevel, enum xer_encoder_flags_e flags,
+                             asn_app_consume_bytes_f *cb, void *app_key) {
+    const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 	asn_enc_rval_t er;
 	uint8_t *buf, *end;
 	uint8_t *ss;	/* Sequence start */
@@ -974,8 +974,10 @@
 /*
  * Convert from the plain UTF-8 format, expanding entity references: "2 &lt; 3"
  */
-static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, size_t chunk_size, int have_more) {
-	OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
+static ssize_t
+OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
+                              size_t chunk_size, int have_more) {
+    OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
 	const char *p = (const char *)chunk_buf;
 	const char *pend = p + chunk_size;
 	uint8_t *buf;
@@ -1115,16 +1117,14 @@
  * Decode OCTET STRING from the XML element's body.
  */
 static asn_dec_rval_t
-OCTET_STRING__decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-	const char *opt_mname, const void *buf_ptr, size_t size,
-	int (*opt_unexpected_tag_decoder)
-		(void *struct_ptr, const void *chunk_buf, size_t chunk_size),
-	ssize_t (*body_receiver)
-		(void *struct_ptr, const void *chunk_buf, size_t chunk_size,
-			int have_more)
-) {
-	OCTET_STRING_t *st = (OCTET_STRING_t *)*sptr;
+OCTET_STRING__decode_xer(
+    const asn_codec_ctx_t *opt_codec_ctx, const asn_TYPE_descriptor_t *td,
+    void **sptr, const char *opt_mname, const void *buf_ptr, size_t size,
+    int (*opt_unexpected_tag_decoder)(void *struct_ptr, const void *chunk_buf,
+                                      size_t chunk_size),
+    ssize_t (*body_receiver)(void *struct_ptr, const void *chunk_buf,
+                             size_t chunk_size, int have_more)) {
+    OCTET_STRING_t *st = (OCTET_STRING_t *)*sptr;
 	const asn_OCTET_STRING_specifics_t *specs = td->specifics
 				? (const asn_OCTET_STRING_specifics_t *)td->specifics
 				: &asn_SPC_OCTET_STRING_specs;
@@ -1176,9 +1176,10 @@
  */
 asn_dec_rval_t
 OCTET_STRING_decode_xer_hex(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-		const char *opt_mname, const void *buf_ptr, size_t size) {
-	return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
+                            const asn_TYPE_descriptor_t *td, void **sptr,
+                            const char *opt_mname, const void *buf_ptr,
+                            size_t size) {
+    return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
 		buf_ptr, size, 0, OCTET_STRING__convert_hexadecimal);
 }
 
@@ -1187,9 +1188,10 @@
  */
 asn_dec_rval_t
 OCTET_STRING_decode_xer_binary(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-		const char *opt_mname, const void *buf_ptr, size_t size) {
-	return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
+                               const asn_TYPE_descriptor_t *td, void **sptr,
+                               const char *opt_mname, const void *buf_ptr,
+                               size_t size) {
+    return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
 		buf_ptr, size, 0, OCTET_STRING__convert_binary);
 }
 
@@ -1198,9 +1200,10 @@
  */
 asn_dec_rval_t
 OCTET_STRING_decode_xer_utf8(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-		const char *opt_mname, const void *buf_ptr, size_t size) {
-	return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
+                             const asn_TYPE_descriptor_t *td, void **sptr,
+                             const char *opt_mname, const void *buf_ptr,
+                             size_t size) {
+    return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
 		buf_ptr, size,
 		OCTET_STRING__handle_control_chars,
 		OCTET_STRING__convert_entrefs);
@@ -1349,7 +1352,7 @@
 
 asn_dec_rval_t
 OCTET_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
-                         asn_TYPE_descriptor_t *td,
+                         const asn_TYPE_descriptor_t *td,
                          const asn_per_constraints_t *constraints, void **sptr,
                          asn_per_data_t *pd) {
     const asn_OCTET_STRING_specifics_t *specs = td->specifics
@@ -1498,9 +1501,9 @@
 }
 
 asn_enc_rval_t
-OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
-                         const asn_per_constraints_t *constraints, void *sptr,
-                         asn_per_outp_t *po) {
+OCTET_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
+                         const asn_per_constraints_t *constraints,
+                         const void *sptr, asn_per_outp_t *po) {
     const asn_OCTET_STRING_specifics_t *specs = td->specifics
 		? (const asn_OCTET_STRING_specifics_t *)td->specifics
 		: &asn_SPC_OCTET_STRING_specs;
@@ -1643,9 +1646,9 @@
 #endif  /* ASN_DISABLE_PER_SUPPORT */
 
 int
-OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const char * const h2c = "0123456789ABCDEF";
+OCTET_STRING_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+    const char * const h2c = "0123456789ABCDEF";
 	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 	char scratch[16 * 3 + 4];
 	char *p = scratch;
@@ -1685,9 +1688,10 @@
 }
 
 int
-OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr,
-		int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
-	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
+OCTET_STRING_print_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
+                        int ilevel, asn_app_consume_bytes_f *cb,
+                        void *app_key) {
+    const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h
index 36b982d..5992850 100644
--- a/skeletons/OCTET_STRING.h
+++ b/skeletons/OCTET_STRING.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_OCTET_STRING_H_
diff --git a/skeletons/OCTET_STRING_oer.c b/skeletons/OCTET_STRING_oer.c
index 3a72166..c2f9a5c 100644
--- a/skeletons/OCTET_STRING_oer.c
+++ b/skeletons/OCTET_STRING_oer.c
@@ -11,7 +11,7 @@
 
 asn_dec_rval_t
 OCTET_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
-                        asn_TYPE_descriptor_t *td,
+                        const asn_TYPE_descriptor_t *td,
                         const asn_oer_constraints_t *constraints, void **sptr,
                         const void *ptr, size_t size) {
     const asn_OCTET_STRING_specifics_t *specs =
@@ -100,13 +100,14 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-OCTET_STRING_encode_oer(asn_TYPE_descriptor_t *td,
-                        const asn_oer_constraints_t *constraints, void *sptr,
-                        asn_app_consume_bytes_f *cb, void *app_key) {
+OCTET_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
+                        const asn_oer_constraints_t *constraints,
+                        const void *sptr, asn_app_consume_bytes_f *cb,
+                        void *app_key) {
     const asn_OCTET_STRING_specifics_t *specs =
         td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
                       : &asn_SPC_OCTET_STRING_specs;
-    OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
+    const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
     const asn_oer_constraints_t *cts =
         constraints ? constraints : td->encoding_constraints.oer_constraints;
     ssize_t ct_size = cts ? cts->size : -1;
diff --git a/skeletons/OPEN_TYPE.c b/skeletons/OPEN_TYPE.c
index 4786799..c672992 100644
--- a/skeletons/OPEN_TYPE.c
+++ b/skeletons/OPEN_TYPE.c
@@ -37,9 +37,9 @@
     } while(0)
 
 asn_dec_rval_t
-OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-                  void *sptr, asn_TYPE_member_t *elm, const void *ptr,
-                  size_t size) {
+OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void *sptr,
+                  const asn_TYPE_member_t *elm, const void *ptr, size_t size) {
     size_t consumed_myself = 0;
     asn_type_selector_result_t selected;
     void *memb_ptr;   /* Pointer to the member */
@@ -122,9 +122,9 @@
 }
 
 asn_dec_rval_t
-OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-                  void *sptr, asn_TYPE_member_t *elm, const void *ptr,
-                  size_t size) {
+OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void *sptr,
+                  const asn_TYPE_member_t *elm, const void *ptr, size_t size) {
     size_t consumed_myself = 0;
     asn_type_selector_result_t selected;
     void *memb_ptr;   /* Pointer to the member */
@@ -287,8 +287,8 @@
 
 asn_dec_rval_t
 OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
-                   asn_TYPE_descriptor_t *td, void *sptr,
-                   asn_TYPE_member_t *elm, asn_per_data_t *pd) {
+                   const asn_TYPE_descriptor_t *td, void *sptr,
+                   const asn_TYPE_member_t *elm, asn_per_data_t *pd) {
     asn_type_selector_result_t selected;
     void *memb_ptr;   /* Pointer to the member */
     void **memb_ptr2; /* Pointer to that pointer */
@@ -361,10 +361,10 @@
 }
 
 asn_enc_rval_t
-OPEN_TYPE_encode_uper(asn_TYPE_descriptor_t *td,
-                      const asn_per_constraints_t *constraints, void *sptr,
-                      asn_per_outp_t *po) {
-    void *memb_ptr;   /* Pointer to the member */
+OPEN_TYPE_encode_uper(const asn_TYPE_descriptor_t *td,
+                      const asn_per_constraints_t *constraints,
+                      const void *sptr, asn_per_outp_t *po) {
+    const void *memb_ptr;   /* Pointer to the member */
     asn_TYPE_member_t *elm; /* CHOICE's element */
     asn_enc_rval_t er;
     unsigned present;
@@ -383,10 +383,11 @@
     elm = &td->elements[present];
     if(elm->flags & ATF_POINTER) {
         /* Member is a pointer to another structure */
-        memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
+        memb_ptr =
+            *(const void *const *)((const char *)sptr + elm->memb_offset);
         if(!memb_ptr) ASN__ENCODE_FAILED;
     } else {
-        memb_ptr = (char *)sptr + elm->memb_offset;
+        memb_ptr = (const char *)sptr + elm->memb_offset;
     }
 
     if(uper_open_type_put(elm->type, NULL, memb_ptr, po) < 0) {
diff --git a/skeletons/OPEN_TYPE.h b/skeletons/OPEN_TYPE.h
index 617fb6a..d0f02fd 100644
--- a/skeletons/OPEN_TYPE.h
+++ b/skeletons/OPEN_TYPE.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2017-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef ASN_OPEN_TYPE_H
@@ -28,33 +28,33 @@
  * by the other members of the parent structure.
  */
 asn_dec_rval_t OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx,
-                                 asn_TYPE_descriptor_t *parent_type,
+                                 const asn_TYPE_descriptor_t *parent_type,
                                  void *parent_structure,
-                                 asn_TYPE_member_t *element, const void *ptr,
-                                 size_t size);
+                                 const asn_TYPE_member_t *element,
+                                 const void *ptr, size_t size);
 
 asn_dec_rval_t OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx,
-                                 asn_TYPE_descriptor_t *parent_type,
+                                 const asn_TYPE_descriptor_t *parent_type,
+                                 void *parent_structure,
+                                 const asn_TYPE_member_t *element,
+                                 const void *ptr, size_t size);
+
+asn_dec_rval_t OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
+                                 const asn_TYPE_descriptor_t *parent_type,
                                  void *parent_structure,
                                  asn_TYPE_member_t *element, const void *ptr,
                                  size_t size);
 
-asn_dec_rval_t OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
-                                  asn_TYPE_descriptor_t *parent_type,
-                                  void *parent_structure,
-                                  asn_TYPE_member_t *element,
-                                  const void *ptr, size_t size);
-
 asn_dec_rval_t OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
-                                  asn_TYPE_descriptor_t *parent_type,
+                                  const asn_TYPE_descriptor_t *parent_type,
                                   void *parent_structure,
-                                  asn_TYPE_member_t *element,
+                                  const asn_TYPE_member_t *element,
                                   asn_per_data_t *pd);
 
-asn_enc_rval_t OPEN_TYPE_encode_uper(asn_TYPE_descriptor_t *type_descriptor,
-                                     const asn_per_constraints_t *constraints,
-                                     void *struct_ptr,
-                                     asn_per_outp_t *per_output);
+asn_enc_rval_t OPEN_TYPE_encode_uper(
+    const asn_TYPE_descriptor_t *type_descriptor,
+    const asn_per_constraints_t *constraints, const void *struct_ptr,
+    asn_per_outp_t *per_output);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/OPEN_TYPE_oer.c b/skeletons/OPEN_TYPE_oer.c
index 30bf099..dd2f5c6 100644
--- a/skeletons/OPEN_TYPE_oer.c
+++ b/skeletons/OPEN_TYPE_oer.c
@@ -8,9 +8,9 @@
 #include <errno.h>
 
 asn_dec_rval_t
-OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-                  void *sptr, asn_TYPE_member_t *elm, const void *ptr,
-                  size_t size) {
+OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void *sptr,
+                  asn_TYPE_member_t *elm, const void *ptr, size_t size) {
     asn_type_selector_result_t selected;
     void *memb_ptr;   /* Pointer to the member */
     void **memb_ptr2; /* Pointer to that pointer */
diff --git a/skeletons/ObjectDescriptor.h b/skeletons/ObjectDescriptor.h
index 2423469..526511e 100644
--- a/skeletons/ObjectDescriptor.h
+++ b/skeletons/ObjectDescriptor.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_ObjectDescriptor_H_
diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c
index 0cf1741..ffc08b7 100644
--- a/skeletons/PrintableString.c
+++ b/skeletons/PrintableString.c
@@ -89,9 +89,10 @@
 
 
 int
-PrintableString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const PrintableString_t *st = (const PrintableString_t *)sptr;
+PrintableString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                           asn_app_constraint_failed_f *ctfailcb,
+                           void *app_key) {
+    const PrintableString_t *st = (const PrintableString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/PrintableString.h b/skeletons/PrintableString.h
index d788944..6a49d16 100644
--- a/skeletons/PrintableString.h
+++ b/skeletons/PrintableString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_PrintableString_H_
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 023afa3..f1d0665 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -306,9 +306,9 @@
 }
 
 int
-REAL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const REAL_t *st = (const REAL_t *)sptr;
+REAL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+           asn_app_consume_bytes_f *cb, void *app_key) {
+    const REAL_t *st = (const REAL_t *)sptr;
 	ssize_t ret;
 	double d;
 
@@ -369,10 +369,10 @@
 }
 
 asn_enc_rval_t
-REAL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	REAL_t *st = (REAL_t *)sptr;
+REAL_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+                void *app_key) {
+    const REAL_t *st = (const REAL_t *)sptr;
 	asn_enc_rval_t er;
 	double d;
 
@@ -392,8 +392,9 @@
  * Decode the chunk of XML text encoding REAL.
  */
 static enum xer_pbd_rval
-REAL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	REAL_t *st = (REAL_t *)sptr;
+REAL__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                      const void *chunk_buf, size_t chunk_size) {
+    REAL_t *st = (REAL_t *)sptr;
 	double value;
 	const char *xerdata = (const char *)chunk_buf;
 	char *endptr = 0;
@@ -458,10 +459,9 @@
 
 asn_dec_rval_t
 REAL_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                const asn_TYPE_descriptor_t *td, void **sptr,
+                const char *opt_mname, const void *buf_ptr, size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(REAL_t), opt_mname,
 		buf_ptr, size, REAL__xer_body_decode);
 }
@@ -846,8 +846,8 @@
  * Encode as Canonical OER
  */
 asn_enc_rval_t
-REAL_encode_oer(asn_TYPE_descriptor_t *td,
-                const asn_oer_constraints_t *constraints, void *sptr,
+REAL_encode_oer(const asn_TYPE_descriptor_t *td,
+                const asn_oer_constraints_t *constraints, const void *sptr,
                 asn_app_consume_bytes_f *cb, void *app_key) {
     const REAL_t *st = sptr;
     asn_enc_rval_t er;
@@ -874,7 +874,8 @@
 }
 
 asn_dec_rval_t
-REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                const asn_TYPE_descriptor_t *td,
                 const asn_oer_constraints_t *constraints, void **sptr,
                 const void *ptr, size_t size) {
     asn_dec_rval_t ok = {RC_OK, 0};
@@ -929,7 +930,8 @@
 #ifndef ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-REAL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+REAL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                 const asn_TYPE_descriptor_t *td,
                  const asn_per_constraints_t *constraints, void **sptr,
                  asn_per_data_t *pd) {
     (void)constraints;	/* No PER visible constraints */
@@ -937,8 +939,8 @@
 }
 
 asn_enc_rval_t
-REAL_encode_uper(asn_TYPE_descriptor_t *td,
-                 const asn_per_constraints_t *constraints, void *sptr,
+REAL_encode_uper(const asn_TYPE_descriptor_t *td,
+                 const asn_per_constraints_t *constraints, const void *sptr,
                  asn_per_outp_t *po) {
     (void)constraints;	/* No PER visible constraints */
 	return OCTET_STRING_encode_uper(td, 0, sptr, po);
diff --git a/skeletons/REAL.h b/skeletons/REAL.h
index af82325..d71147a 100644
--- a/skeletons/REAL.h
+++ b/skeletons/REAL.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_TYPE_REAL_H
diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c
index 18fbdb3..2f6295b 100644
--- a/skeletons/RELATIVE-OID.c
+++ b/skeletons/RELATIVE-OID.c
@@ -93,9 +93,9 @@
 }
 
 int
-RELATIVE_OID_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
+RELATIVE_OID_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+    const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
@@ -114,8 +114,9 @@
 }
 
 static enum xer_pbd_rval
-RELATIVE_OID__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
-	RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
+RELATIVE_OID__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
+                              const void *chunk_buf, size_t chunk_size) {
+    RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
 	const char *chunk_end = (const char *)chunk_buf + chunk_size;
 	const char *endptr;
 	asn_oid_arc_t s_arcs[6];
@@ -157,19 +158,19 @@
 
 asn_dec_rval_t
 RELATIVE_OID_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-
-	return xer_decode_primitive(opt_codec_ctx, td,
+                        const asn_TYPE_descriptor_t *td, void **sptr,
+                        const char *opt_mname, const void *buf_ptr,
+                        size_t size) {
+    return xer_decode_primitive(opt_codec_ctx, td,
 		sptr, sizeof(RELATIVE_OID_t), opt_mname,
 			buf_ptr, size, RELATIVE_OID__xer_body_decode);
 }
 
 asn_enc_rval_t
-RELATIVE_OID_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
+RELATIVE_OID_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                        int ilevel, enum xer_encoder_flags_e flags,
+                        asn_app_consume_bytes_f *cb, void *app_key) {
+    const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
 	asn_enc_rval_t er;
 
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/RELATIVE-OID.h b/skeletons/RELATIVE-OID.h
index edae83d..289bbca 100644
--- a/skeletons/RELATIVE-OID.h
+++ b/skeletons/RELATIVE-OID.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_RELATIVE_OID_H_
diff --git a/skeletons/T61String.h b/skeletons/T61String.h
index 27f7cc6..3f4707a 100644
--- a/skeletons/T61String.h
+++ b/skeletons/T61String.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_T61String_H_
diff --git a/skeletons/TeletexString.h b/skeletons/TeletexString.h
index 59d0ef7..a43f3e3 100644
--- a/skeletons/TeletexString.h
+++ b/skeletons/TeletexString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_TeletexString_H_
diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c
index d645869..ffbed58 100644
--- a/skeletons/UTCTime.c
+++ b/skeletons/UTCTime.c
@@ -74,18 +74,17 @@
  * Check that the time looks like the time.
  */
 int
-UTCTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const UTCTime_t *st = (const UTCTime_t *)sptr;
+UTCTime_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const UTCTime_t *st = (const UTCTime_t *)sptr;
 	time_t tloc;
 
 	errno = EPERM;			/* Just an unlikely error code */
 	tloc = asn_UT2time(st, 0, 0);
 	if(tloc == -1 && errno != EPERM) {
-		ASN__CTFAIL(app_key, td, sptr,
-			"%s: Invalid time format: %s (%s:%d)",
-			td->name, strerror(errno), __FILE__, __LINE__);
-		return -1;
+        ASN__CTFAIL(app_key, td, sptr, "%s: Invalid time format: %s (%s:%d)",
+                    td->name, strerror(errno), __FILE__, __LINE__);
+        return -1;
 	}
 
 	return 0;
@@ -94,17 +93,16 @@
 #ifndef	ASN___INTERNAL_TEST_MODE
 
 asn_enc_rval_t
-UTCTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-
-	if(flags & XER_F_CANONICAL) {
+UTCTime_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                   int ilevel, enum xer_encoder_flags_e flags,
+                   asn_app_consume_bytes_f *cb, void *app_key) {
+    if(flags & XER_F_CANONICAL) {
 		asn_enc_rval_t rv;
 		UTCTime_t *ut;
 		struct tm tm;
 
 		errno = EPERM;
-		if(asn_UT2time((UTCTime_t *)sptr, &tm, 1) == -1
+		if(asn_UT2time((const UTCTime_t *)sptr, &tm, 1) == -1
 				&& errno != EPERM)
 			ASN__ENCODE_FAILED;
 
@@ -125,9 +123,9 @@
 #endif	/* ASN___INTERNAL_TEST_MODE */
 
 int
-UTCTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const UTCTime_t *st = (const UTCTime_t *)sptr;
+UTCTime_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+              asn_app_consume_bytes_f *cb, void *app_key) {
+    const UTCTime_t *st = (const UTCTime_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/UTCTime.h b/skeletons/UTCTime.h
index 23234fa..3c5c0c4 100644
--- a/skeletons/UTCTime.h
+++ b/skeletons/UTCTime.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_UTCTime_H_
diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c
index ae48063..a82da36 100644
--- a/skeletons/UTF8String.c
+++ b/skeletons/UTF8String.c
@@ -84,9 +84,9 @@
 #define	U8E_EINVAL	-5	/* Invalid arguments */
 
 int
-UTF8String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	ssize_t len = UTF8String_length((const UTF8String_t *)sptr);
+UTF8String_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    ssize_t len = UTF8String_length((const UTF8String_t *)sptr);
 	switch(len) {
 	case U8E_EINVAL:
 		ASN__CTFAIL(app_key, td, sptr,
@@ -185,9 +185,9 @@
 }
 
 int
-UTF8String_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const UTF8String_t *st = (const UTF8String_t *)sptr;
+UTF8String_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                 asn_app_consume_bytes_f *cb, void *app_key) {
+    const UTF8String_t *st = (const UTF8String_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/UTF8String.h b/skeletons/UTF8String.h
index 4deec26..0304483 100644
--- a/skeletons/UTF8String.h
+++ b/skeletons/UTF8String.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_UTF8String_H_
diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c
index 67fb6a1..e4a08d5 100644
--- a/skeletons/UniversalString.c
+++ b/skeletons/UniversalString.c
@@ -64,13 +64,13 @@
 };
 
 int
-UniversalString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
+UniversalString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
                            asn_app_constraint_failed_f *ctfailcb,
                            void *app_key) {
     const UniversalString_t *st = (const UniversalString_t *)sptr;
 
     if(st && st->buf) {
-        if(st->size & 3) {
+        if(st->size % 4) {
             ASN__CTFAIL(app_key, td, sptr,
                         "%s: invalid size %zu not divisible by 4 (%s:%d)",
                         td->name, st->size, __FILE__, __LINE__);
@@ -146,9 +146,10 @@
 
 asn_dec_rval_t
 UniversalString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td, void **sptr,
-		const char *opt_mname, const void *buf_ptr, size_t size) {
-	asn_dec_rval_t rc;
+                           const asn_TYPE_descriptor_t *td, void **sptr,
+                           const char *opt_mname, const void *buf_ptr,
+                           size_t size) {
+    asn_dec_rval_t rc;
 
 	rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
 		buf_ptr, size);
@@ -202,10 +203,10 @@
 }
 
 asn_enc_rval_t
-UniversalString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const UniversalString_t *st = (const UniversalString_t *)sptr;
+UniversalString_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                           int ilevel, enum xer_encoder_flags_e flags,
+                           asn_app_consume_bytes_f *cb, void *app_key) {
+    const UniversalString_t *st = (const UniversalString_t *)sptr;
 	asn_enc_rval_t er;
 
 	(void)ilevel;
@@ -221,9 +222,9 @@
 }
 
 int
-UniversalString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const UniversalString_t *st = (const UniversalString_t *)sptr;
+UniversalString_print(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+    const UniversalString_t *st = (const UniversalString_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
@@ -236,36 +237,3 @@
 	return 0;
 }
 
-/*
- * Biased function for randomizing UCS-4 sequences.
- */
-static size_t
-UniversalString__random_char(uint8_t *b) {
-    uint32_t code;
-
-    switch(asn_random_between(0, 4)) {
-    case 0:
-        code = 0;
-        break;
-    case 1:
-        code = 1;
-        break;
-    case 2:
-        code = 0xd7ff;  /* End of pre-surrogate block */
-        break;
-    case 3:
-        code = 0xe000;  /* Beginning of post-surrogate block */
-        break;
-    case 4:
-        code = 0x10ffff;
-        break;
-    }
-
-    b[0] = code >> 24;
-    b[1] = code >> 16;
-    b[2] = code >> 8;
-    b[3] = code;
-
-    return 4;
-}
-
diff --git a/skeletons/UniversalString.h b/skeletons/UniversalString.h
index b2673ae..df0c07a 100644
--- a/skeletons/UniversalString.h
+++ b/skeletons/UniversalString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_UniversalString_H_
diff --git a/skeletons/VideotexString.h b/skeletons/VideotexString.h
index 1227f58..37177d3 100644
--- a/skeletons/VideotexString.h
+++ b/skeletons/VideotexString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_VideotexString_H_
diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c
index fe2762f..e163791 100644
--- a/skeletons/VisibleString.c
+++ b/skeletons/VisibleString.c
@@ -58,9 +58,9 @@
 };
 
 int
-VisibleString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const VisibleString_t *st = (const VisibleString_t *)sptr;
+VisibleString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const VisibleString_t *st = (const VisibleString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/VisibleString.h b/skeletons/VisibleString.h
index a8d278b..842d56e 100644
--- a/skeletons/VisibleString.h
+++ b/skeletons/VisibleString.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_VisibleString_H_
diff --git a/skeletons/asn_SEQUENCE_OF.h b/skeletons/asn_SEQUENCE_OF.h
index e678f03..e35bc44 100644
--- a/skeletons/asn_SEQUENCE_OF.h
+++ b/skeletons/asn_SEQUENCE_OF.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_SEQUENCE_OF_H
diff --git a/skeletons/asn_SET_OF.h b/skeletons/asn_SET_OF.h
index a2067d8..882e1a4 100644
--- a/skeletons/asn_SET_OF.h
+++ b/skeletons/asn_SET_OF.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_SET_OF_H
diff --git a/skeletons/asn_application.c b/skeletons/asn_application.c
index 2cb9b19..5b25207 100644
--- a/skeletons/asn_application.c
+++ b/skeletons/asn_application.c
@@ -6,10 +6,12 @@
 #include <asn_application.h>
 #include <errno.h>
 
-static asn_enc_rval_t asn_encode_internal(
-    const asn_codec_ctx_t *opt_codec_ctx,
-    enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
-    void *sptr, asn_app_consume_bytes_f *callback, void *callback_key);
+static asn_enc_rval_t asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
+                                          enum asn_transfer_syntax syntax,
+                                          const asn_TYPE_descriptor_t *td,
+                                          const void *sptr,
+                                          asn_app_consume_bytes_f *callback,
+                                          void *callback_key);
 
 
 struct callback_count_bytes_key {
@@ -113,8 +115,9 @@
 
 asn_enc_rval_t
 asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
-                     enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
-                     void *sptr, void *buffer, size_t buffer_size) {
+                     enum asn_transfer_syntax syntax,
+                     const asn_TYPE_descriptor_t *td, const void *sptr,
+                     void *buffer, size_t buffer_size) {
     struct overrun_encoder_key buf_key;
     asn_enc_rval_t er;
 
@@ -141,9 +144,9 @@
 
 static asn_enc_rval_t
 asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
-                    enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
-                    void *sptr, asn_app_consume_bytes_f *callback,
-                    void *callback_key) {
+                    enum asn_transfer_syntax syntax,
+                    const asn_TYPE_descriptor_t *td, const void *sptr,
+                    asn_app_consume_bytes_f *callback, void *callback_key) {
     asn_enc_rval_t er;
     enum xer_encoder_flags_e xer_flags = XER_F_CANONICAL;
 
@@ -303,9 +306,8 @@
 
 asn_dec_rval_t
 asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
-           enum asn_transfer_syntax syntax, struct asn_TYPE_descriptor_s *td,
+           enum asn_transfer_syntax syntax, const asn_TYPE_descriptor_t *td,
            void **sptr, const void *buffer, size_t size) {
-
     if(!td || !td->op || !sptr || (size && !buffer)) {
         ASN__DECODE_FAILED;
     }
diff --git a/skeletons/asn_application.h b/skeletons/asn_application.h
index d75a2ce..a125562 100644
--- a/skeletons/asn_application.h
+++ b/skeletons/asn_application.h
@@ -78,9 +78,8 @@
 asn_enc_rval_t asn_encode_to_buffer(
     const asn_codec_ctx_t *opt_codec_parameters, /* See asn_codecs.h */
     enum asn_transfer_syntax,
-    struct asn_TYPE_descriptor_s *type_to_encode,
-    void *structure_to_encode,
-    void *buffer, size_t buffer_size);
+    const struct asn_TYPE_descriptor_s *type_to_encode,
+    const void *structure_to_encode, void *buffer, size_t buffer_size);
 
 
 /*
@@ -118,11 +117,11 @@
  */
 asn_dec_rval_t asn_decode(
     const asn_codec_ctx_t *opt_codec_parameters, enum asn_transfer_syntax,
-    struct asn_TYPE_descriptor_s *type_to_decode,
+    const struct asn_TYPE_descriptor_s *type_to_decode,
     void **structure_ptr, /* Pointer to a target structure's pointer */
     const void *buffer,   /* Data to be decoded */
     size_t size           /* Size of that buffer */
-    );
+);
 
 
 /*
@@ -134,7 +133,7 @@
  * particular constraint has failed.
  */
 typedef void (asn_app_constraint_failed_f)(void *application_specific_key,
-	struct asn_TYPE_descriptor_s *type_descriptor_which_failed,
+	const struct asn_TYPE_descriptor_s *type_descriptor_which_failed,
 	const void *structure_which_failed_ptr,
 	const char *error_message_format, ...) CC_PRINTFLIKE(4, 5);
 
diff --git a/skeletons/asn_bit_data.h b/skeletons/asn_bit_data.h
index 750522b..8b13663 100644
--- a/skeletons/asn_bit_data.h
+++ b/skeletons/asn_bit_data.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_BIT_DATA
diff --git a/skeletons/asn_codecs.h b/skeletons/asn_codecs.h
index 4b2a294..e75c270 100644
--- a/skeletons/asn_codecs.h
+++ b/skeletons/asn_codecs.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+/*
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_CODECS_H
@@ -52,10 +51,10 @@
 	 */
 
 	/* Type which cannot be encoded */
-	struct asn_TYPE_descriptor_s *failed_type;
+	const struct asn_TYPE_descriptor_s *failed_type;
 
 	/* Pointer to the structure of that type */
-	void *structure_ptr;
+	const void *structure_ptr;
 } asn_enc_rval_t;
 #define	ASN__ENCODE_FAILED do {					\
 	asn_enc_rval_t tmp_error;				\
diff --git a/skeletons/asn_codecs_prim.c b/skeletons/asn_codecs_prim.c
index f15a18d..78448a8 100644
--- a/skeletons/asn_codecs_prim.c
+++ b/skeletons/asn_codecs_prim.c
@@ -11,9 +11,9 @@
  */
 asn_dec_rval_t
 ber_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td,
-	void **sptr, const void *buf_ptr, size_t size, int tag_mode) {
-	ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
+                     const asn_TYPE_descriptor_t *td, void **sptr,
+                     const void *buf_ptr, size_t size, int tag_mode) {
+    ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
 	asn_dec_rval_t rval;
 	ber_tlv_len_t length = 0; /* =0 to avoid [incorrect] warning. */
 
@@ -81,11 +81,11 @@
  * Encode an always-primitive type using DER.
  */
 asn_enc_rval_t
-der_encode_primitive(asn_TYPE_descriptor_t *td, void *sptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t erval;
-	ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
+der_encode_primitive(const asn_TYPE_descriptor_t *td, const void *sptr,
+                     int tag_mode, ber_tlv_tag_t tag,
+                     asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_enc_rval_t erval;
+	const ASN__PRIMITIVE_TYPE_t *st = (const ASN__PRIMITIVE_TYPE_t *)sptr;
 
 	ASN_DEBUG("%s %s as a primitive type (tm=%d)",
 		cb?"Encoding":"Estimating", td->name, tag_mode);
@@ -144,8 +144,8 @@
  * Local internal type passed around as an argument.
  */
 struct xdp_arg_s {
-	asn_TYPE_descriptor_t *type_descriptor;
-	void *struct_key;
+    const asn_TYPE_descriptor_t *type_descriptor;
+    void *struct_key;
 	xer_primitive_body_decoder_f *prim_body_decoder;
 	int decoded_something;
 	int want_more;
@@ -249,14 +249,11 @@
 
 asn_dec_rval_t
 xer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *td,
-	void **sptr,
-	size_t struct_size,
-	const char *opt_mname,
-	const void *buf_ptr, size_t size,
-	xer_primitive_body_decoder_f *prim_body_decoder
-) {
-	const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
+                     const asn_TYPE_descriptor_t *td, void **sptr,
+                     size_t struct_size, const char *opt_mname,
+                     const void *buf_ptr, size_t size,
+                     xer_primitive_body_decoder_f *prim_body_decoder) {
+    const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
 	asn_struct_ctx_t s_ctx;
 	struct xdp_arg_s s_arg;
 	asn_dec_rval_t rc;
diff --git a/skeletons/asn_codecs_prim.h b/skeletons/asn_codecs_prim.h
index 917c892..3399ee7 100644
--- a/skeletons/asn_codecs_prim.h
+++ b/skeletons/asn_codecs_prim.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_CODECS_PRIM_H
@@ -30,21 +30,19 @@
 	XPBD_NOT_BODY_IGNORE,	/* Not a body format, but safe to ignore */
 	XPBD_BODY_CONSUMED	/* Body is recognized and consumed */
 };
-typedef enum xer_pbd_rval (xer_primitive_body_decoder_f)
-	(asn_TYPE_descriptor_t *td, void *struct_ptr,
-		const void *chunk_buf, size_t chunk_size);
+typedef enum xer_pbd_rval(xer_primitive_body_decoder_f)(
+    const asn_TYPE_descriptor_t *td, void *struct_ptr,
+    const void *chunk_buf, size_t chunk_size);
 
 /*
  * Specific function to decode simple primitive types.
  * Also see xer_decode_general() in xer_decoder.h
  */
-asn_dec_rval_t xer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *type_descriptor,
-	void **struct_ptr, size_t struct_size,
-	const char *opt_mname,
-	const void *buf_ptr, size_t size,
-	xer_primitive_body_decoder_f *prim_body_decoder
-);
+asn_dec_rval_t xer_decode_primitive(
+    const asn_codec_ctx_t *opt_codec_ctx,
+    const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
+    size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size,
+    xer_primitive_body_decoder_f *prim_body_decoder);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h
index e308182..74ae1dc 100644
--- a/skeletons/asn_internal.h
+++ b/skeletons/asn_internal.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2003, 2004, 2005, 2007 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+/*
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
diff --git a/skeletons/asn_random_fill.h b/skeletons/asn_random_fill.h
index bfaa13e..47f9b8a 100644
--- a/skeletons/asn_random_fill.h
+++ b/skeletons/asn_random_fill.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN_RANDOM_FILL
diff --git a/skeletons/asn_system.h b/skeletons/asn_system.h
index 6dbd148..eacacc4 100644
--- a/skeletons/asn_system.h
+++ b/skeletons/asn_system.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
diff --git a/skeletons/ber_decoder.c b/skeletons/ber_decoder.c
index fffd1a1..75d6016 100644
--- a/skeletons/ber_decoder.c
+++ b/skeletons/ber_decoder.c
@@ -28,9 +28,9 @@
  */
 asn_dec_rval_t
 ber_decode(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *type_descriptor,
-	void **struct_ptr, const void *ptr, size_t size) {
-	asn_codec_ctx_t s_codec_ctx;
+           const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
+           const void *ptr, size_t size) {
+    asn_codec_ctx_t s_codec_ctx;
 
 	/*
 	 * Stack checker requires that the codec context
@@ -63,10 +63,10 @@
  */
 asn_dec_rval_t
 ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx,
-		asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
-		const void *ptr, size_t size, int tag_mode, int last_tag_form,
-		ber_tlv_len_t *last_length, int *opt_tlv_form) {
-	ssize_t consumed_myself = 0;
+               const asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
+               const void *ptr, size_t size, int tag_mode, int last_tag_form,
+               ber_tlv_len_t *last_length, int *opt_tlv_form) {
+    ssize_t consumed_myself = 0;
 	ssize_t tag_len;
 	ssize_t len_len;
 	ber_tlv_tag_t tlv_tag;
diff --git a/skeletons/ber_decoder.h b/skeletons/ber_decoder.h
index e9907bd..1ac2a5e 100644
--- a/skeletons/ber_decoder.h
+++ b/skeletons/ber_decoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BER_DECODER_H_
@@ -22,21 +22,21 @@
  * NOTE: Use the der_encode() function (der_encoder.h) to produce encoding
  * which is compliant with ber_decode().
  */
-asn_dec_rval_t ber_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	void **struct_ptr,	/* Pointer to a target structure's pointer */
-	const void *buffer,	/* Data to be decoded */
-	size_t size		/* Size of that buffer */
-	);
+asn_dec_rval_t ber_decode(
+    const struct asn_codec_ctx_s *opt_codec_ctx,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    void **struct_ptr,  /* Pointer to a target structure's pointer */
+    const void *buffer, /* Data to be decoded */
+    size_t size         /* Size of that buffer */
+);
 
 /*
  * Type of generic function which decodes the byte stream into the structure.
  */
-typedef asn_dec_rval_t (ber_type_decoder_f)(
-		const struct asn_codec_ctx_s *opt_codec_ctx,
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		void **struct_ptr, const void *buf_ptr, size_t size,
-		int tag_mode);
+typedef asn_dec_rval_t(ber_type_decoder_f)(
+    const struct asn_codec_ctx_s *opt_codec_ctx,
+    const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,
+    const void *buf_ptr, size_t size, int tag_mode);
 
 /*******************************
  * INTERNALLY USEFUL FUNCTIONS *
@@ -50,15 +50,14 @@
  * head->last_tag_form is non-zero.
  */
 asn_dec_rval_t ber_check_tags(
-		const struct asn_codec_ctx_s *opt_codec_ctx,	/* codec options */
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		asn_struct_ctx_t *opt_ctx,	/* saved decoding context */
-		const void *ptr, size_t size,
-		int tag_mode,		/* {-1,0,1}: IMPLICIT, no, EXPLICIT */
-		int last_tag_form,	/* {-1,0:1}: any, primitive, constr */
-		ber_tlv_len_t *last_length,
-		int *opt_tlv_form	/* optional tag form */
-	);
+    const struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    asn_struct_ctx_t *opt_ctx, /* saved decoding context */
+    const void *ptr, size_t size,
+    int tag_mode,      /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
+    int last_tag_form, /* {-1,0:1}: any, primitive, constr */
+    ber_tlv_len_t *last_length, int *opt_tlv_form /* optional tag form */
+);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/ber_tlv_length.h b/skeletons/ber_tlv_length.h
index f7f95e5..d1e4d48 100644
--- a/skeletons/ber_tlv_length.h
+++ b/skeletons/ber_tlv_length.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BER_TLV_LENGTH_H_
diff --git a/skeletons/ber_tlv_tag.h b/skeletons/ber_tlv_tag.h
index 60e8668..ce227ad 100644
--- a/skeletons/ber_tlv_tag.h
+++ b/skeletons/ber_tlv_tag.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_BER_TLV_TAG_H_
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index 49c389d..628979e 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #include <asn_internal.h>
@@ -103,9 +102,10 @@
  * The decoder of the CHOICE type.
  */
 asn_dec_rval_t
-CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
-	/*
+CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                  const void *ptr, size_t size, int tag_mode) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_CHOICE_specifics_t *specs =
@@ -360,13 +360,13 @@
 }
 
 asn_enc_rval_t
-CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
-		int tag_mode, ber_tlv_tag_t tag,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
+CHOICE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                  int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
+                  void *app_key) {
+    const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
 	asn_TYPE_member_t *elm;	/* CHOICE element */
 	asn_enc_rval_t erval;
-	void *memb_ptr;
+	const void *memb_ptr;
 	size_t computed_size = 0;
 	unsigned present;
 
@@ -396,8 +396,9 @@
 	 */
 	elm = &td->elements[present-1];
 	if(elm->flags & ATF_POINTER) {
-		memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
-		if(memb_ptr == 0) {
+        memb_ptr =
+            *(const void *const *)((const char *)sptr + elm->memb_offset);
+        if(memb_ptr == 0) {
 			if(elm->optional) {
 				erval.encoded = 0;
 				ASN__ENCODED_OK(erval);
@@ -406,8 +407,8 @@
 			ASN__ENCODE_FAILED;
 		}
 	} else {
-		memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-	}
+        memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+    }
 
 	/*
 	 * If the CHOICE itself is tagged EXPLICIT:
@@ -483,10 +484,11 @@
 }
 
 int
-CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
-	unsigned present;
+CHOICE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                  asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const asn_CHOICE_specifics_t *specs =
+        (const asn_CHOICE_specifics_t *)td->specifics;
+    unsigned present;
 
 	if(!sptr) {
 		ASN__CTFAIL(app_key, td, sptr,
@@ -544,10 +546,10 @@
  * Decode the XER (XML) data.
  */
 asn_dec_rval_t
-CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-	/*
+CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                  const char *opt_mname, const void *buf_ptr, size_t size) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
@@ -774,11 +776,12 @@
 
 
 asn_enc_rval_t
-CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const asn_CHOICE_specifics_t *specs=(const asn_CHOICE_specifics_t *)td->specifics;
-	asn_enc_rval_t er;
+CHOICE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                  enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+                  void *app_key) {
+    const asn_CHOICE_specifics_t *specs =
+        (const asn_CHOICE_specifics_t *)td->specifics;
+    asn_enc_rval_t er;
 	unsigned present;
 
 	if(!sptr)
@@ -794,18 +797,19 @@
 	}  else {
 		asn_enc_rval_t tmper;
 		asn_TYPE_member_t *elm = &td->elements[present-1];
-		void *memb_ptr;
+		const void *memb_ptr;
 		const char *mname = elm->name;
 		unsigned int mlen = strlen(mname);
 
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
-			if(!memb_ptr) ASN__ENCODE_FAILED;
+            memb_ptr =
+                *(const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!memb_ptr) ASN__ENCODE_FAILED;
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-		}
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+        }
 
-		er.encoded = 0;
+        er.encoded = 0;
 
 		if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel);
 		ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
@@ -826,7 +830,8 @@
 }
 
 asn_dec_rval_t
-CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                   const asn_TYPE_descriptor_t *td,
                    const asn_per_constraints_t *constraints, void **sptr,
                    asn_per_data_t *pd) {
     const asn_CHOICE_specifics_t *specs =
@@ -878,8 +883,11 @@
 	}
 
 	/* Adjust if canonical order is different from natural order */
-	if(specs->canonical_order)
-		value = specs->canonical_order[value];
+	if(specs->from_canonical_order) {
+        ASN_DEBUG("CHOICE presence from wire %d", value);
+		value = specs->from_canonical_order[value];
+        ASN_DEBUG("CHOICE presence index effective %d", value);
+    }
 
 	/* Set presence to be able to free it later */
 	_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
@@ -909,13 +917,13 @@
 }
 
 asn_enc_rval_t
-CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
-                   const asn_per_constraints_t *constraints, void *sptr,
+CHOICE_encode_uper(const asn_TYPE_descriptor_t *td,
+                   const asn_per_constraints_t *constraints, const void *sptr,
                    asn_per_outp_t *po) {
-	const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
+    const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
 	asn_TYPE_member_t *elm;	/* CHOICE's element */
 	const asn_per_constraint_t *ct;
-	void *memb_ptr;
+	const void *memb_ptr;
 	unsigned present;
 	int present_enc;
 
@@ -941,17 +949,20 @@
 
 	ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
 
-	/* Adjust if canonical order is different from natural order */
-	if(specs->canonical_order)
-		present_enc = specs->canonical_order[present];
-	else
-		present_enc = present;
+    /* Adjust if canonical order is different from natural order */
+    if(specs->to_canonical_order)
+        present_enc = specs->to_canonical_order[present];
+    else
+        present_enc = present;
 
-	if(ct && ct->range_bits >= 0) {
+    if(ct && ct->range_bits >= 0) {
 		if(present_enc < ct->lower_bound
 		|| present_enc > ct->upper_bound) {
 			if(ct->flags & APC_EXTENSIBLE) {
-				if(per_put_few_bits(po, 1, 1))
+                ASN_DEBUG(
+                    "CHOICE member %d (enc %d) is an extension (%ld..%ld)",
+                    present, present_enc, ct->lower_bound, ct->upper_bound);
+                if(per_put_few_bits(po, 1, 1))
 					ASN__ENCODE_FAILED;
 			} else {
 				ASN__ENCODE_FAILED;
@@ -959,44 +970,51 @@
 			ct = 0;
 		}
 	}
-	if(ct && ct->flags & APC_EXTENSIBLE)
-		if(per_put_few_bits(po, 0, 1))
+	if(ct && ct->flags & APC_EXTENSIBLE) {
+        ASN_DEBUG("CHOICE member %d (enc %d) is not an extension (%ld..%ld)",
+                  present, present_enc, ct->lower_bound, ct->upper_bound);
+        if(per_put_few_bits(po, 0, 1))
 			ASN__ENCODE_FAILED;
+    }
+
 
 	elm = &td->elements[present];
-	if(elm->flags & ATF_POINTER) {
+    ASN_DEBUG("CHOICE member \"%s\" %d (as %d)", elm->name, present,
+              present_enc);
+    if(elm->flags & ATF_POINTER) {
 		/* Member is a pointer to another structure */
-		memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
-		if(!memb_ptr) ASN__ENCODE_FAILED;
+        memb_ptr =
+            *(const void *const *)((const char *)sptr + elm->memb_offset);
+        if(!memb_ptr) ASN__ENCODE_FAILED;
 	} else {
-		memb_ptr = (char *)sptr + elm->memb_offset;
-	}
+        memb_ptr = (const char *)sptr + elm->memb_offset;
+    }
 
-	if(ct && ct->range_bits >= 0) {
-		if(per_put_few_bits(po, present_enc, ct->range_bits))
-			ASN__ENCODE_FAILED;
+    if(ct && ct->range_bits >= 0) {
+        if(per_put_few_bits(po, present_enc, ct->range_bits))
+            ASN__ENCODE_FAILED;
 
-		return elm->type->op->uper_encoder(elm->type, elm->encoding_constraints.per_constraints,
-			memb_ptr, po);
-	} else {
-		asn_enc_rval_t rval;
-		if(specs->ext_start == -1)
-			ASN__ENCODE_FAILED;
-		if(uper_put_nsnnwn(po, present_enc - specs->ext_start))
-			ASN__ENCODE_FAILED;
-		if(uper_open_type_put(elm->type, elm->encoding_constraints.per_constraints,
-			memb_ptr, po))
-			ASN__ENCODE_FAILED;
-		rval.encoded = 0;
-		ASN__ENCODED_OK(rval);
-	}
+        return elm->type->op->uper_encoder(
+            elm->type, elm->encoding_constraints.per_constraints, memb_ptr, po);
+    } else {
+        asn_enc_rval_t rval;
+        if(specs->ext_start == -1) ASN__ENCODE_FAILED;
+        if(uper_put_nsnnwn(po, present_enc - specs->ext_start))
+            ASN__ENCODE_FAILED;
+        if(uper_open_type_put(elm->type,
+                              elm->encoding_constraints.per_constraints,
+                              memb_ptr, po))
+            ASN__ENCODE_FAILED;
+        rval.encoded = 0;
+        ASN__ENCODED_OK(rval);
+    }
 }
-   
+
 
 int
-CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
+CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+             asn_app_consume_bytes_f *cb, void *app_key) {
+    const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
 	unsigned present;
 
 	if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
diff --git a/skeletons/constr_CHOICE.h b/skeletons/constr_CHOICE.h
index 57d58a9..7649480 100644
--- a/skeletons/constr_CHOICE.h
+++ b/skeletons/constr_CHOICE.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+/*
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_CONSTR_CHOICE_H_
@@ -28,7 +27,8 @@
 	unsigned tag2el_count;
 
 	/* Canonical ordering of CHOICE elements, for PER */
-	const unsigned *canonical_order;
+	const unsigned *to_canonical_order;
+	const unsigned *from_canonical_order;
 
 	/*
 	 * Extensions-related stuff.
diff --git a/skeletons/constr_CHOICE_oer.c b/skeletons/constr_CHOICE_oer.c
index 39310b0..6480a96 100644
--- a/skeletons/constr_CHOICE_oer.c
+++ b/skeletons/constr_CHOICE_oer.c
@@ -125,7 +125,8 @@
 }
 
 asn_dec_rval_t
-CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td,
                   const asn_oer_constraints_t *constraints, void **struct_ptr,
                   const void *ptr, size_t size) {
     /*
@@ -314,14 +315,14 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-CHOICE_encode_oer(asn_TYPE_descriptor_t *td,
-                  const asn_oer_constraints_t *constraints, void *sptr,
+CHOICE_encode_oer(const asn_TYPE_descriptor_t *td,
+                  const asn_oer_constraints_t *constraints, const void *sptr,
                   asn_app_consume_bytes_f *cb, void *app_key) {
     const asn_CHOICE_specifics_t *specs =
         (const asn_CHOICE_specifics_t *)td->specifics;
     asn_TYPE_member_t *elm; /* CHOICE element */
     unsigned present;
-    void *memb_ptr;
+    const void *memb_ptr;
     ber_tlv_tag_t tag;
     ssize_t tag_len;
     asn_enc_rval_t er = {0, 0, 0};
@@ -340,13 +341,14 @@
 
     elm = &td->elements[present-1];
     if(elm->flags & ATF_POINTER) {
-        memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
+        memb_ptr =
+            *(const void *const *)((const char *)sptr + elm->memb_offset);
         if(memb_ptr == 0) {
             /* Mandatory element absent */
             ASN__ENCODE_FAILED;
         }
     } else {
-        memb_ptr = (void *)((char *)sptr + elm->memb_offset);
+        memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
     }
 
     tag = asn_TYPE_outmost_tag(elm->type, memb_ptr, elm->tag_mode, elm->tag);
@@ -359,7 +361,7 @@
         ASN__ENCODE_FAILED;
     }
 
-    if(specs->ext_start >= 0 && specs->ext_start <= (present-1)) {
+    if(specs->ext_start >= 0 && (unsigned)specs->ext_start <= (present-1)) {
         ssize_t encoded = oer_open_type_put(elm->type,
                                elm->encoding_constraints.oer_constraints,
                                memb_ptr, cb, app_key);
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index d4c16a6..46af34f 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -110,15 +110,16 @@
  * The decoder of the SEQUENCE type.
  */
 asn_dec_rval_t
-SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
-	/*
+SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
+                    const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                    const void *ptr, size_t size, int tag_mode) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elements = td->elements;
+    const asn_TYPE_member_t *elements = td->elements;
 
-	/*
+    /*
 	 * Parts of the structure being constructed.
 	 */
 	void *st = *struct_ptr;	/* Target structure. */
@@ -515,10 +516,10 @@
  * The DER encoder of the SEQUENCE type.
  */
 asn_enc_rval_t
-SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
-	void *sptr, int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	size_t computed_size = 0;
+SEQUENCE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                    int tag_mode, ber_tlv_tag_t tag,
+                    asn_app_consume_bytes_f *cb, void *app_key) {
+    size_t computed_size = 0;
 	asn_enc_rval_t erval;
 	ssize_t ret;
 	size_t edx;
@@ -532,12 +533,13 @@
 	for(edx = 0; edx < td->elements_count; edx++) {
 		asn_TYPE_member_t *elm = &td->elements[edx];
 
-		void *memb_ptr;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
+		const void *memb_ptr;		/* Pointer to the member */
+        const void *const *memb_ptr2; /* Pointer to that pointer */
 
-		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			if(!*memb_ptr2) {
+        if(elm->flags & ATF_POINTER) {
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!*memb_ptr2) {
 				ASN_DEBUG("Element %s %zu not present",
 					elm->name, edx);
 				if(elm->optional)
@@ -546,12 +548,12 @@
 				ASN__ENCODE_FAILED;
 			}
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr;
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr;
 		}
 
 		/* Eliminate default values */
-		if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
+		if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
 			continue;
 
 		erval = elm->type->op->der_encoder(elm->type, *memb_ptr2,
@@ -581,20 +583,21 @@
 	for(edx = 0; edx < td->elements_count; edx++) {
 		asn_TYPE_member_t *elm = &td->elements[edx];
 		asn_enc_rval_t tmperval;
-		void *memb_ptr;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
+        const void *memb_ptr;           /* Pointer to the member */
+        const void *const *memb_ptr2;   /* Pointer to that pointer */
 
-		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			if(!*memb_ptr2) continue;
+        if(elm->flags & ATF_POINTER) {
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!*memb_ptr2) continue;
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr;
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr;
 		}
 
 		/* Eliminate default values */
-		if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
-			continue;
+        if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
+            continue;
 
 		tmperval = elm->type->op->der_encoder(elm->type, *memb_ptr2,
 			elm->tag_mode, elm->tag, cb, app_key);
@@ -628,10 +631,10 @@
  * Decode the XER (XML) data.
  */
 asn_dec_rval_t
-SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const char *opt_mname,
-		const void *ptr, size_t size) {
-	/*
+SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
+                    const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                    const char *opt_mname, const void *ptr, size_t size) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SEQUENCE_specifics_t *specs
@@ -876,9 +879,9 @@
 }
 
 asn_enc_rval_t
-SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
-                    enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
-                    void *app_key) {
+SEQUENCE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                    int ilevel, enum xer_encoder_flags_e flags,
+                    asn_app_consume_bytes_f *cb, void *app_key) {
     asn_enc_rval_t er;
     int xcan = (flags & XER_F_CANONICAL);
     asn_TYPE_descriptor_t *tmp_def_val_td = 0;
@@ -892,16 +895,17 @@
     for(edx = 0; edx < td->elements_count; edx++) {
         asn_enc_rval_t tmper;
         asn_TYPE_member_t *elm = &td->elements[edx];
-        void *memb_ptr;
+        const void *memb_ptr;
         const char *mname = elm->name;
         unsigned int mlen = strlen(mname);
 
         if(elm->flags & ATF_POINTER) {
-            memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
+            memb_ptr =
+                *(const void *const *)((const char *)sptr + elm->memb_offset);
             if(!memb_ptr) {
                 assert(tmp_def_val == 0);
-                if(elm->default_value) {
-                    if(elm->default_value(1, &tmp_def_val)) {
+                if(elm->default_value_set) {
+                    if(elm->default_value_set(&tmp_def_val)) {
                         ASN__ENCODE_FAILED;
                     } else {
                         memb_ptr = tmp_def_val;
@@ -915,7 +919,7 @@
                 }
             }
         } else {
-            memb_ptr = (void *)((char *)sptr + elm->memb_offset);
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
         }
 
         if(!xcan) ASN__TEXT_INDENT(1, ilevel);
@@ -943,9 +947,9 @@
 }
 
 int
-SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	size_t edx;
+SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+               asn_app_consume_bytes_f *cb, void *app_key) {
+    size_t edx;
 	int ret;
 
 	if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
@@ -1035,9 +1039,9 @@
 }
 
 int
-SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	size_t edx;
+SEQUENCE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                    asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    size_t edx;
 
 	if(!sptr) {
 		ASN__CTFAIL(app_key, td, sptr,
@@ -1083,10 +1087,11 @@
 #ifndef ASN_DISABLE_PER_SUPPORT
 
 asn_dec_rval_t
-SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                     const asn_TYPE_descriptor_t *td,
                      const asn_per_constraints_t *constraints, void **sptr,
                      asn_per_data_t *pd) {
-	const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
+    const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
 	void *st = *sptr;	/* Target structure. */
 	int extpresent;		/* Extension additions are present */
 	uint8_t *opres;		/* Presence of optional root members */
@@ -1159,9 +1164,9 @@
 				(int)opmd.nboff, (int)opmd.nbits);
 			if(present == 0) {
 				/* This element is not present */
-				if(elm->default_value) {
+				if(elm->default_value_set) {
 					/* Fill-in DEFAULT */
-					if(elm->default_value(1, memb_ptr2)) {
+					if(elm->default_value_set(memb_ptr2)) {
 						FREEMEM(opres);
 						ASN__DECODE_FAILED;
 					}
@@ -1281,7 +1286,7 @@
 		asn_TYPE_member_t *elm = &td->elements[edx];
 		void **memb_ptr2;	/* Pointer to member pointer */
 
-		if(!elm->default_value) continue;
+		if(!elm->default_value_set) continue;
 
 		/* Fetch the pointer to this member */
 		if(elm->flags & ATF_POINTER) {
@@ -1293,8 +1298,8 @@
 		}
 
 		/* Set default value */
-		if(elm->default_value(1, memb_ptr2)) {
-			ASN__DECODE_FAILED;
+        if(elm->default_value_set(memb_ptr2)) {
+            ASN__DECODE_FAILED;
 		}
 	}
 
@@ -1304,9 +1309,9 @@
 }
 
 static int
-SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
-		asn_per_outp_t *po1, asn_per_outp_t *po2) {
-	const asn_SEQUENCE_specifics_t *specs
+SEQUENCE__handle_extensions(const asn_TYPE_descriptor_t *td, const void *sptr,
+                            asn_per_outp_t *po1, asn_per_outp_t *po2) {
+    const asn_SEQUENCE_specifics_t *specs
 		= (const asn_SEQUENCE_specifics_t *)td->specifics;
 	int exts_present = 0;
 	int exts_count = 0;
@@ -1318,9 +1323,9 @@
 	/* Find out which extensions are present */
 	for(edx = specs->ext_after + 1; edx < td->elements_count; edx++) {
 		asn_TYPE_member_t *elm = &td->elements[edx];
-		void *memb_ptr;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
-		int present;
+        const void *memb_ptr; /* Pointer to the member */
+        const void *const *memb_ptr2; /* Pointer to that pointer */
+        int present;
 
 		if(!IN_EXTENSION_GROUP(specs, edx)) {
 			ASN_DEBUG("%s (@%zu) is not extension", elm->type->name, edx);
@@ -1329,11 +1334,12 @@
 
 		/* Fetch the pointer to this member */
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			present = (*memb_ptr2 != 0);
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            present = (*memb_ptr2 != 0);
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr;
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr;
 			present = 1;
 		}
 
@@ -1356,10 +1362,10 @@
 }
 
 asn_enc_rval_t
-SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
-                     const asn_per_constraints_t *constraints, void *sptr,
+SEQUENCE_encode_uper(const asn_TYPE_descriptor_t *td,
+                     const asn_per_constraints_t *constraints, const void *sptr,
                      asn_per_outp_t *po) {
-	const asn_SEQUENCE_specifics_t *specs
+    const asn_SEQUENCE_specifics_t *specs
 		= (const asn_SEQUENCE_specifics_t *)td->specifics;
 	asn_enc_rval_t er;
 	int n_extensions;
@@ -1381,7 +1387,7 @@
 	 * and whether to encode extensions
 	 */
 	if(specs->ext_before >= 0) {
-		n_extensions = SEQUENCE_handle_extensions(td, sptr, 0, 0);
+		n_extensions = SEQUENCE__handle_extensions(td, sptr, 0, 0);
 		if(n_extensions < 0)
 			ASN__ENCODE_FAILED;
 		if(per_put_few_bits(po, n_extensions ? 1 : 0, 1))
@@ -1393,31 +1399,32 @@
 	/* Encode a presence bitmap */
 	for(i = 0; i < specs->roms_count; i++) {
 		asn_TYPE_member_t *elm;
-		void *memb_ptr;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
-		int present;
+		const void *memb_ptr;		/* Pointer to the member */
+        const void *const *memb_ptr2; /* Pointer to that pointer */
+        int present;
 
 		edx = specs->oms[i];
 		elm = &td->elements[edx];
 
 		/* Fetch the pointer to this member */
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			present = (*memb_ptr2 != 0);
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            present = (*memb_ptr2 != 0);
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr;
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr;
 			present = 1;
 		}
 
 		/* Eliminate default values */
-		if(present && elm->default_value
-		&& elm->default_value(0, memb_ptr2) == 1)
-			present = 0;
+        if(present && elm->default_value_cmp
+           && elm->default_value_cmp(*memb_ptr2) == 0)
+            present = 0;
 
 		ASN_DEBUG("Element %s %s %s->%s is %s",
 			elm->flags & ATF_POINTER ? "ptr" : "inline",
-			elm->default_value ? "def" : "wtv",
+			elm->default_value_cmp ? "def" : "wtv",
 			td->name, elm->name, present ? "present" : "absent");
 		if(per_put_few_bits(po, present, 1))
 			ASN__ENCODE_FAILED;
@@ -1431,18 +1438,19 @@
 		? td->elements_count : specs->ext_before - 1); edx++) {
 
 		asn_TYPE_member_t *elm = &td->elements[edx];
-		void *memb_ptr;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
+        const void *memb_ptr;         /* Pointer to the member */
+        const void *const *memb_ptr2; /* Pointer to that pointer */
 
-		if(IN_EXTENSION_GROUP(specs, edx))
+        if(IN_EXTENSION_GROUP(specs, edx))
 			continue;
 
 		ASN_DEBUG("About to encode %s", elm->type->name);
 
 		/* Fetch the pointer to this member */
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			if(!*memb_ptr2) {
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!*memb_ptr2) {
 				ASN_DEBUG("Element %s %zu not present",
 					elm->name, edx);
 				if(elm->optional)
@@ -1451,12 +1459,12 @@
 				ASN__ENCODE_FAILED;
 			}
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr;
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr;
 		}
 
 		/* Eliminate default values */
-		if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
+		if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
 			continue;
 
 		ASN_DEBUG("Encoding %s->%s", td->name, elm->name);
@@ -1477,12 +1485,12 @@
 	ASN_DEBUG("Bit-map of %d elements", n_extensions);
 	/* #18.7. Encoding the extensions presence bit-map. */
 	/* TODO: act upon NOTE in #18.7 for canonical PER */
-	if(SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions)
+	if(SEQUENCE__handle_extensions(td, sptr, po, 0) != n_extensions)
 		ASN__ENCODE_FAILED;
 
 	ASN_DEBUG("Writing %d extensions", n_extensions);
 	/* #18.9. Encode extensions as open type fields. */
-	if(SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions)
+	if(SEQUENCE__handle_extensions(td, sptr, 0, po) != n_extensions)
 		ASN__ENCODE_FAILED;
 
 	ASN__ENCODED_OK(er);
diff --git a/skeletons/constr_SEQUENCE.h b/skeletons/constr_SEQUENCE.h
index fd44353..01d0311 100644
--- a/skeletons/constr_SEQUENCE.h
+++ b/skeletons/constr_SEQUENCE.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_CONSTR_SEQUENCE_H_
diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c
index fa60786..7d63540 100644
--- a/skeletons/constr_SEQUENCE_OF.c
+++ b/skeletons/constr_SEQUENCE_OF.c
@@ -11,11 +11,11 @@
  * The DER encoder of the SEQUENCE OF type.
  */
 asn_enc_rval_t
-SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_TYPE_member_t *elm = td->elements;
-	asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(ptr);
+SEQUENCE_OF_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr,
+                       int tag_mode, ber_tlv_tag_t tag,
+                       asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_TYPE_member_t *elm = td->elements;
+	const asn_anonymous_sequence_ *list = _A_CSEQUENCE_FROM_VOID(ptr);
 	size_t computed_size = 0;
 	ssize_t encoding_size = 0;
 	asn_enc_rval_t erval;
@@ -88,17 +88,17 @@
 }
 
 asn_enc_rval_t
-SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
-                       enum xer_encoder_flags_e flags,
+SEQUENCE_OF_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                       int ilevel, enum xer_encoder_flags_e flags,
                        asn_app_consume_bytes_f *cb, void *app_key) {
     asn_enc_rval_t er;
     const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
-    asn_TYPE_member_t *elm = td->elements;
-    asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr);
+    const asn_TYPE_member_t *elm = td->elements;
+    const asn_anonymous_sequence_ *list = _A_CSEQUENCE_FROM_VOID(sptr);
     const char *mname = specs->as_XMLValueList
                             ? 0
                             : ((*elm->name) ? elm->name : elm->type->xml_tag);
-    unsigned int mlen = mname ? strlen(mname) : 0;
+    size_t mlen = mname ? strlen(mname) : 0;
     int xcan = (flags & XER_F_CANONICAL);
     int i;
 
@@ -140,19 +140,19 @@
 }
 
 asn_enc_rval_t
-SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
-                        const asn_per_constraints_t *constraints, void *sptr,
-                        asn_per_outp_t *po) {
-	asn_anonymous_sequence_ *list;
+SEQUENCE_OF_encode_uper(const asn_TYPE_descriptor_t *td,
+                        const asn_per_constraints_t *constraints,
+                        const void *sptr, asn_per_outp_t *po) {
+    const asn_anonymous_sequence_ *list;
 	const asn_per_constraint_t *ct;
 	asn_enc_rval_t er;
-	asn_TYPE_member_t *elm = td->elements;
+	const asn_TYPE_member_t *elm = td->elements;
 	int seq;
 
 	if(!sptr) ASN__ENCODE_FAILED;
-	list = _A_SEQUENCE_FROM_VOID(sptr);
+    list = _A_CSEQUENCE_FROM_VOID(sptr);
 
-	er.encoded = 0;
+    er.encoded = 0;
 
 	ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count);
 
diff --git a/skeletons/constr_SEQUENCE_OF.h b/skeletons/constr_SEQUENCE_OF.h
index c2acc6a..45204f3 100644
--- a/skeletons/constr_SEQUENCE_OF.h
+++ b/skeletons/constr_SEQUENCE_OF.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_CONSTR_SEQUENCE_OF_H_
diff --git a/skeletons/constr_SEQUENCE_oer.c b/skeletons/constr_SEQUENCE_oer.c
index 4e71596..9906af9 100644
--- a/skeletons/constr_SEQUENCE_oer.c
+++ b/skeletons/constr_SEQUENCE_oer.c
@@ -66,17 +66,20 @@
     }
 }
 
-static void *element_ptr(void *struct_ptr, asn_TYPE_member_t *elm) {
+static const void *
+element_ptr(const void *struct_ptr, const asn_TYPE_member_t *elm) {
     if(elm->flags & ATF_POINTER) {
         /* Member is a pointer to another structure */
-        return *(void **)((char *)struct_ptr + elm->memb_offset);
+        return *(const void *const *)((const char *)struct_ptr
+                                      + elm->memb_offset);
     } else {
-        return (void *)((char *)struct_ptr + elm->memb_offset);
+        return (const void *)((const char *)struct_ptr + elm->memb_offset);
     }
 }
 
 asn_dec_rval_t
-SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                    const asn_TYPE_descriptor_t *td,
                     const asn_oer_constraints_t *constraints, void **struct_ptr,
                     const void *ptr, size_t size) {
     const asn_SEQUENCE_specifics_t *specs =
@@ -177,11 +180,11 @@
                     ASN_DEBUG("Presence map ended prematurely: %d", present);
                     RETURN(RC_FAIL);
                 } else if(present == 0) {
-                    if(elm->default_value) {
+                    if(elm->default_value_set) {
                         /* Fill-in DEFAULT */
                         void *tmp;
-                        if(elm->default_value(1,
-                                              element_ptrptr(st, elm, &tmp))) {
+                        if(elm->default_value_set(
+                               element_ptrptr(st, elm, &tmp))) {
                             RETURN(RC_FAIL);
                         }
                     }
@@ -322,7 +325,8 @@
                 /* Fall through */
             case 0:
                 /* Fill-in DEFAULT */
-                if(elm->default_value && elm->default_value(1, memb_ptr2)) {
+                if(elm->default_value_set
+                   && elm->default_value_set(memb_ptr2)) {
                     RETURN(RC_FAIL);
                 }
                 continue;
@@ -388,8 +392,8 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
-                    const asn_oer_constraints_t *constraints, void *sptr,
+SEQUENCE_encode_oer(const asn_TYPE_descriptor_t *td,
+                    const asn_oer_constraints_t *constraints, const void *sptr,
                     asn_app_consume_bytes_f *cb, void *app_key) {
     const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
     size_t computed_size = 0;
@@ -412,10 +416,10 @@
             for(edx = specs->ext_after + 1;
                 (ssize_t)edx < specs->ext_before - 1; edx++) {
                 asn_TYPE_member_t *elm = &td->elements[edx];
-                void *memb_ptr = element_ptr(sptr, elm);
+                const void *memb_ptr = element_ptr(sptr, elm);
                 if(memb_ptr) {
-                    if(elm->default_value
-                       && elm->default_value(0, &memb_ptr) == 1) {
+                    if(elm->default_value_cmp
+                       && elm->default_value_cmp(memb_ptr) == 0) {
                         /* Do not encode default values in extensions */
                     } else {
                         has_extensions = 1;
@@ -440,10 +444,10 @@
                 if(IN_EXTENSION_GROUP(specs, edx)) break;
 
                 if(elm->optional) {
-                    void *memb_ptr = element_ptr(sptr, elm);
+                    const void *memb_ptr = element_ptr(sptr, elm);
                     uint32_t has_component = memb_ptr != NULL;
-                    if(has_component && elm->default_value
-                       && elm->default_value(0, &memb_ptr) == 1) {
+                    if(has_component && elm->default_value_cmp
+                       && elm->default_value_cmp(&memb_ptr) == 0) {
                         has_component = 0;
                     }
                     ret = asn_put_few_bits(&preamble, has_component, 1);
@@ -464,13 +468,14 @@
     for(edx = 0; edx < td->elements_count; edx++) {
         asn_TYPE_member_t *elm = &td->elements[edx];
         asn_enc_rval_t er;
-        void *memb_ptr;
+        const void *memb_ptr;
 
         if(IN_EXTENSION_GROUP(specs, edx)) break;
 
         memb_ptr = element_ptr(sptr, elm);
         if(memb_ptr) {
-            if(elm->default_value && elm->default_value(0, &memb_ptr) == 1) {
+            if(elm->default_value_cmp
+               && elm->default_value_cmp(memb_ptr) == 0) {
                 /* Skip default values in encoding */
                 continue;
             }
@@ -524,9 +529,9 @@
         for(edx = specs->ext_after + 1; (ssize_t)edx < specs->ext_before - 1;
             edx++) {
             asn_TYPE_member_t *elm = &td->elements[edx];
-            void *memb_ptr = element_ptr(sptr, elm);
-            if(memb_ptr && elm->default_value
-               && elm->default_value(0, &memb_ptr) == 1) {
+            const void *memb_ptr = element_ptr(sptr, elm);
+            if(memb_ptr && elm->default_value_cmp
+               && elm->default_value_cmp(memb_ptr) == 0) {
                 memb_ptr = 0;   /* Do not encode default value. */
             }
             ret |= asn_put_few_bits(&extadds, memb_ptr ? 1 : 0, 1);
@@ -540,11 +545,11 @@
         for(edx = specs->ext_after + 1; (ssize_t)edx < specs->ext_before - 1;
             edx++) {
             asn_TYPE_member_t *elm = &td->elements[edx];
-            void *memb_ptr = element_ptr(sptr, elm);
+            const void *memb_ptr = element_ptr(sptr, elm);
 
             if(memb_ptr) {
-                if(elm->default_value
-                   && elm->default_value(0, &memb_ptr) == 1) {
+                if(elm->default_value_cmp
+                   && elm->default_value_cmp(memb_ptr) == 0) {
                     /* Do not encode default value. */
                 } else {
                     asn_enc_rval_t er = elm->type->op->oer_encoder(
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index 422e663..4f0230c 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -7,7 +7,7 @@
 #include <constr_SET.h>
 
 /* Check that all the mandatory members are present */
-static int _SET_is_populated(asn_TYPE_descriptor_t *td, void *st);
+static int _SET_is_populated(const asn_TYPE_descriptor_t *td, const void *st);
 
 /*
  * Number of bytes left for this structure.
@@ -94,13 +94,14 @@
  * The decoder of the SET type.
  */
 asn_dec_rval_t
-SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
-	/*
+SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
+               const asn_TYPE_descriptor_t *td, void **struct_ptr,
+               const void *ptr, size_t size, int tag_mode) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elements = td->elements;
+	const asn_TYPE_member_t *elements = td->elements;
 
 	/*
 	 * Parts of the structure being constructed.
@@ -392,8 +393,8 @@
 }
 
 static int
-_SET_is_populated(asn_TYPE_descriptor_t *td, void *st) {
-	const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
+_SET_is_populated(const asn_TYPE_descriptor_t *td, const void *st) {
+    const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
 	size_t edx;
 
 	/*
@@ -404,8 +405,9 @@
 		unsigned int midx, pres, must;
 
 		midx = edx/(8 * sizeof(specs->_mandatory_elements[0]));
-		pres = ((unsigned int *)((char *)st + specs->pres_offset))[midx];
-		must = sys_ntohl(specs->_mandatory_elements[midx]);
+        pres = ((const unsigned int *)((const char *)st
+                                       + specs->pres_offset))[midx];
+        must = sys_ntohl(specs->_mandatory_elements[midx]);
 
 		if((pres & must) == must) {
 			/*
@@ -432,10 +434,9 @@
  * The DER encoder of the SET type.
  */
 asn_enc_rval_t
-SET_encode_der(asn_TYPE_descriptor_t *td,
-	void *sptr, int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
+SET_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr, int tag_mode,
+               ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
+    const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
 	size_t computed_size = 0;
 	asn_enc_rval_t er;
 	int t2m_build_own = (specs->tag2el_count != td->elements_count);
@@ -467,15 +468,16 @@
 	for(edx = 0; edx < td->elements_count; edx++) {
 		asn_TYPE_member_t *elm = &td->elements[edx];
 		asn_enc_rval_t tmper;
-		void *memb_ptr_dontuse; /* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
+		const void *memb_ptr_dontuse; /* Pointer to the member */
+        const void *const *memb_ptr2; /* Pointer to that pointer */
 
-		/*
+        /*
 		 * Compute the length of the encoding of this member.
 		 */
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			if(!*memb_ptr2) {
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!*memb_ptr2) {
 				if(!elm->optional) {
 					/* Mandatory elements missing */
 					FREEMEM(t2m_build);
@@ -489,13 +491,14 @@
 				continue;
 			}
 		} else {
-			memb_ptr_dontuse = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
+            memb_ptr_dontuse =
+                (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
 		}
 
 		/* Eliminate default values */
-		if(elm->default_value && elm->default_value(0, memb_ptr2) == 1) {
-			if(t2m_build) {
+        if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0) {
+            if(t2m_build) {
 				t2m_build[t2m_count].el_no = edx;
 				t2m_build[t2m_count].el_tag = 0;
 				t2m_count++;
@@ -566,23 +569,25 @@
 		asn_TYPE_member_t *elm;
 		asn_enc_rval_t tmper;
 
-		void *memb_ptr_dontuse;		/* Pointer to the member */
-		void **memb_ptr2;	/* Pointer to that pointer */
+		const void *memb_ptr_dontuse;		/* Pointer to the member */
+        const void *const *memb_ptr2;       /* Pointer to that pointer */
 
-		/* Encode according to the tag order */
+        /* Encode according to the tag order */
 		elm = &td->elements[t2m[edx].el_no];
 
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
-			if(!*memb_ptr2) continue;
+            memb_ptr2 =
+                (const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!*memb_ptr2) continue;
 		} else {
-			memb_ptr_dontuse = (void *)((char *)sptr + elm->memb_offset);
-			memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
+            memb_ptr_dontuse =
+                (const void *)((const char *)sptr + elm->memb_offset);
+            memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
 		}
 
 		/* Eliminate default values */
-		if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
-			continue;
+        if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
+            continue;
 
 		tmper = elm->type->op->der_encoder(elm->type, *memb_ptr2,
 			elm->tag_mode, elm->tag, cb, app_key);
@@ -615,14 +620,14 @@
  * Decode the XER (XML) data.
  */
 asn_dec_rval_t
-SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-	/*
+SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
+               const asn_TYPE_descriptor_t *td, void **struct_ptr,
+               const char *opt_mname, const void *buf_ptr, size_t size) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elements = td->elements;
+	const asn_TYPE_member_t *elements = td->elements;
 	const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
 
 	/*
@@ -660,7 +665,7 @@
 		pxer_chunk_type_e ch_type;	/* XER chunk type */
 		ssize_t ch_size;		/* Chunk size */
 		xer_check_tag_e tcv;		/* Tag check value */
-		asn_TYPE_member_t *elm;
+		const asn_TYPE_member_t *elm;
 
 		/*
 		 * Go inside the inner member of a set.
@@ -831,10 +836,10 @@
 }
 
 asn_enc_rval_t
-SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
+SET_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+               enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+               void *app_key) {
+    const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
 	asn_enc_rval_t er;
 	int xcan = (flags & XER_F_CANONICAL);
 	const asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer;
@@ -851,25 +856,26 @@
 	for(edx = 0; edx < t2m_count; edx++) {
 		asn_enc_rval_t tmper;
 		asn_TYPE_member_t *elm;
-		void *memb_ptr;
-		const char *mname;
-		unsigned int mlen;
+        const void *memb_ptr;
+        const char *mname;
+		size_t mlen;
 
 		elm = &td->elements[t2m[edx].el_no];
 		mname = elm->name;
 		mlen = strlen(elm->name);
 
 		if(elm->flags & ATF_POINTER) {
-			memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
-			if(!memb_ptr) {
+            memb_ptr =
+                *(const void *const *)((const char *)sptr + elm->memb_offset);
+            if(!memb_ptr) {
 				if(elm->optional)
 					continue;
 				/* Mandatory element missing */
 				ASN__ENCODE_FAILED;
 			}
 		} else {
-			memb_ptr = (void *)((char *)sptr + elm->memb_offset);
-		}
+            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
+        }
 
 		if(!xcan)
 			ASN__TEXT_INDENT(1, ilevel);
@@ -892,9 +898,9 @@
 }
 
 int
-SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	size_t edx;
+SET_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+          asn_app_consume_bytes_f *cb, void *app_key) {
+    size_t edx;
 	int ret;
 
 	if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
@@ -975,9 +981,9 @@
 }
 
 int
-SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	size_t edx;
+SET_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+               asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    size_t edx;
 
 	if(!sptr) {
 		ASN__CTFAIL(app_key, td, sptr,
diff --git a/skeletons/constr_SET.h b/skeletons/constr_SET.h
index 489355a..d64a00f 100644
--- a/skeletons/constr_SET.h
+++ b/skeletons/constr_SET.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_CONSTR_SET_H_
diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c
index 54ced1f..f3f5294 100644
--- a/skeletons/constr_SET_OF.c
+++ b/skeletons/constr_SET_OF.c
@@ -66,15 +66,16 @@
  * The decoder of the SET OF type.
  */
 asn_dec_rval_t
-SET_OF_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
-	/*
+SET_OF_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                  const void *ptr, size_t size, int tag_mode) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elm = td->elements;	/* Single one */
+    const asn_TYPE_member_t *elm = td->elements; /* Single one */
 
-	/*
+    /*
 	 * Parts of the structure being constructed.
 	 */
 	void *st = *struct_ptr;	/* Target structure. */
@@ -310,14 +311,14 @@
  * The DER encoder of the SET OF type.
  */
 asn_enc_rval_t
-SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
-	int tag_mode, ber_tlv_tag_t tag,
-	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_TYPE_member_t *elm = td->elements;
-	asn_TYPE_descriptor_t *elm_type = elm->type;
+SET_OF_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
+                  int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
+                  void *app_key) {
+    const asn_TYPE_member_t *elm = td->elements;
+	const asn_TYPE_descriptor_t *elm_type = elm->type;
 	der_type_encoder_f *der_encoder = elm_type->op->der_encoder;
-	asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
-	size_t computed_size = 0;
+    const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
+    size_t computed_size = 0;
 	ssize_t encoding_size = 0;
 	struct _el_buffer *encoded_els;
 	ssize_t eels_count = 0;
@@ -334,8 +335,8 @@
 	for(edx = 0; edx < list->count; edx++) {
 		void *memb_ptr = list->array[edx];
 		if(!memb_ptr) continue;
-		erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
-		if(erval.encoded == -1)
+        erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
+        if(erval.encoded == -1)
 			return erval;
 		computed_size += erval.encoded;
 
@@ -352,7 +353,7 @@
 	if(encoding_size == -1) {
 		erval.encoded = -1;
 		erval.failed_type = td;
-		erval.structure_ptr = ptr;
+		erval.structure_ptr = sptr;
 		return erval;
 	}
 	computed_size += encoding_size;
@@ -367,22 +368,19 @@
 	 * according to their encodings. Build an array of the
 	 * encoded elements.
 	 */
-	encoded_els = (struct _el_buffer *)MALLOC(
-				list->count * sizeof(encoded_els[0]));
-	if(encoded_els == NULL) {
-		erval.encoded = -1;
-		erval.failed_type = td;
-		erval.structure_ptr = ptr;
-		return erval;
-	}
+    encoded_els =
+        (struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
+    if(encoded_els == NULL) {
+        ASN__ENCODE_FAILED;
+    }
 
-	ASN_DEBUG("Encoding members of %s SET OF", td->name);
+    ASN_DEBUG("Encoding members of %s SET OF", td->name);
 
 	/*
 	 * Encode all members.
 	 */
 	for(edx = 0; edx < list->count; edx++) {
-		void *memb_ptr = list->array[edx];
+		const void *memb_ptr = list->array[edx];
 		struct _el_buffer *encoded_el = &encoded_els[eels_count];
 
 		if(!memb_ptr) continue;
@@ -398,10 +396,7 @@
 			for(edx--; edx >= 0; edx--)
 				FREEMEM(encoded_els[edx].buf);
 			FREEMEM(encoded_els);
-			erval.encoded = -1;
-			erval.failed_type = td;
-			erval.structure_ptr = ptr;
-			return erval;
+            ASN__ENCODE_FAILED;
 		}
 
 		/*
@@ -444,14 +439,11 @@
 		 * Standard callback failed, or
 		 * encoded size is not equal to the computed size.
 		 */
-		erval.encoded = -1;
-		erval.failed_type = td;
-		erval.structure_ptr = ptr;
+        ASN__ENCODE_FAILED;
 	} else {
 		erval.encoded = computed_size;
-	}
-
-	ASN__ENCODED_OK(erval);
+        ASN__ENCODED_OK(erval);
+    }
 }
 
 #undef	XER_ADVANCE
@@ -466,14 +458,14 @@
  * Decode the XER (XML) data.
  */
 asn_dec_rval_t
-SET_OF_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-	void **struct_ptr, const char *opt_mname,
-		const void *buf_ptr, size_t size) {
-	/*
+SET_OF_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td, void **struct_ptr,
+                  const char *opt_mname, const void *buf_ptr, size_t size) {
+    /*
 	 * Bring closer parts of structure description.
 	 */
 	const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
-	asn_TYPE_member_t *element = td->elements;
+	const asn_TYPE_member_t *element = td->elements;
 	const char *elm_tag;
 	const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
 
@@ -651,14 +643,14 @@
 
 
 asn_enc_rval_t
-SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
-	int ilevel, enum xer_encoder_flags_e flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t er;
+SET_OF_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+                  enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
+                  void *app_key) {
+    asn_enc_rval_t er;
 	const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elm = td->elements;
-	asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr);
-	const char *mname = specs->as_XMLValueList
+	const asn_TYPE_member_t *elm = td->elements;
+    const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
+    const char *mname = specs->as_XMLValueList
 		? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag);
 	size_t mlen = mname ? strlen(mname) : 0;
 	int xcan = (flags & XER_F_CANONICAL);
@@ -750,9 +742,9 @@
 }
 
 int
-SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_TYPE_member_t *elm = td->elements;
+SET_OF_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
+             asn_app_consume_bytes_f *cb, void *app_key) {
+    asn_TYPE_member_t *elm = td->elements;
 	const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
 	int ret;
 	int i;
@@ -825,9 +817,9 @@
 }
 
 int
-SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
-		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
-	asn_TYPE_member_t *elm = td->elements;
+SET_OF_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                  asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+    const asn_TYPE_member_t *elm = td->elements;
 	asn_constr_check_f *constr;
 	const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
 	int i;
@@ -860,13 +852,14 @@
 }
 
 asn_dec_rval_t
-SET_OF_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+SET_OF_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
+                   const asn_TYPE_descriptor_t *td,
                    const asn_per_constraints_t *constraints, void **sptr,
                    asn_per_data_t *pd) {
-	asn_dec_rval_t rv;
+    asn_dec_rval_t rv;
 	const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
-	asn_TYPE_member_t *elm = td->elements;	/* Single one */
-	void *st = *sptr;
+    const asn_TYPE_member_t *elm = td->elements; /* Single one */
+    void *st = *sptr;
 	asn_anonymous_set_ *list;
 	const asn_per_constraint_t *ct;
 	int repeat = 0;
diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h
index b5c9819..f32e607 100644
--- a/skeletons/constr_SET_OF.h
+++ b/skeletons/constr_SET_OF.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	CONSTR_SET_OF_H
diff --git a/skeletons/constr_SET_OF_oer.c b/skeletons/constr_SET_OF_oer.c
index 0008fa9..1357c2b 100644
--- a/skeletons/constr_SET_OF_oer.c
+++ b/skeletons/constr_SET_OF_oer.c
@@ -107,9 +107,10 @@
 }
 
 asn_dec_rval_t
-SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-                    const asn_oer_constraints_t *constraints, void **struct_ptr,
-                    const void *ptr, size_t size) {
+SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
+                  const asn_TYPE_descriptor_t *td,
+                  const asn_oer_constraints_t *constraints, void **struct_ptr,
+                  const void *ptr, size_t size) {
     const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
     asn_dec_rval_t rval = {RC_OK, 0};
     void *st = *struct_ptr; /* Target structure */
@@ -227,13 +228,13 @@
  * Encode as Canonical OER.
  */
 asn_enc_rval_t
-SET_OF_encode_oer(asn_TYPE_descriptor_t *td,
-                    const asn_oer_constraints_t *constraints, void *sptr,
-                    asn_app_consume_bytes_f *cb, void *app_key) {
+SET_OF_encode_oer(const asn_TYPE_descriptor_t *td,
+                  const asn_oer_constraints_t *constraints, const void *sptr,
+                  asn_app_consume_bytes_f *cb, void *app_key) {
+    const asn_TYPE_member_t *elm;
+    const asn_anonymous_set_ *list;
     size_t computed_size = 0;
     ssize_t qty_len;
-    asn_TYPE_member_t *elm;
-    asn_anonymous_set_ *list;
     int n;
 
     (void)constraints;
@@ -241,7 +242,7 @@
     if(!sptr) ASN__ENCODE_FAILED;
 
     elm = td->elements;
-    list = _A_SET_FROM_VOID(sptr);
+    list = _A_CSET_FROM_VOID(sptr);
 
     qty_len = oer_put_quantity(list->count, cb, app_key);
     if(qty_len < 0) {
diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h
index 7810349..089f891 100644
--- a/skeletons/constr_TYPE.h
+++ b/skeletons/constr_TYPE.h
@@ -1,6 +1,5 @@
-/*-
- * Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+/*
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 /*
@@ -97,11 +96,11 @@
 /*
  * Print the structure according to its specification.
  */
-typedef int (asn_struct_print_f)(
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		const void *struct_ptr,
-		int level,	/* Indentation level */
-		asn_app_consume_bytes_f *callback, void *app_key);
+typedef int(asn_struct_print_f)(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr,
+    int level, /* Indentation level */
+    asn_app_consume_bytes_f *callback, void *app_key);
 
 /*
  * Compare two structs between each other.
@@ -131,7 +130,7 @@
  * Information Object Set driven constraints.
  */
 typedef struct asn_type_selector_result_s {
-    struct asn_TYPE_descriptor_s *type_descriptor; /* Type encoded. */
+    const struct asn_TYPE_descriptor_s *type_descriptor; /* Type encoded. */
     unsigned presence_index; /* Associated choice variant. */
 } asn_type_selector_result_t;
 typedef asn_type_selector_result_t(asn_type_selector_f)(
@@ -227,7 +226,8 @@
     asn_TYPE_descriptor_t *type;            /* Member type descriptor */
     asn_type_selector_f *type_selector;     /* IoS runtime type selector */
     asn_encoding_constraints_t encoding_constraints;
-    int (*default_value)(int setval, void **sptr); /* DEFAULT <value> */
+    int (*default_value_set)(void **sptr);      /* Set DEFAULT <value> */
+    int (*default_value_cmp)(const void *sptr); /* Compare DEFAULT <value> */
     const char *name; /* ASN.1 identifier of the element */
 } asn_TYPE_member_t;
 
diff --git a/skeletons/constraints.c b/skeletons/constraints.c
index c260997..df3c6c1 100644
--- a/skeletons/constraints.c
+++ b/skeletons/constraints.c
@@ -2,10 +2,10 @@
 #include <constraints.h>
 
 int
-asn_generic_no_constraint(asn_TYPE_descriptor_t *type_descriptor,
-	const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) {
-
-	(void)type_descriptor;	/* Unused argument */
+asn_generic_no_constraint(const asn_TYPE_descriptor_t *type_descriptor,
+                          const void *struct_ptr,
+                          asn_app_constraint_failed_f *cb, void *key) {
+    (void)type_descriptor;	/* Unused argument */
 	(void)struct_ptr;	/* Unused argument */
 	(void)cb;	/* Unused argument */
 	(void)key;	/* Unused argument */
@@ -15,10 +15,10 @@
 }
 
 int
-asn_generic_unknown_constraint(asn_TYPE_descriptor_t *type_descriptor,
-	const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) {
-
-	(void)type_descriptor;	/* Unused argument */
+asn_generic_unknown_constraint(const asn_TYPE_descriptor_t *type_descriptor,
+                               const void *struct_ptr,
+                               asn_app_constraint_failed_f *cb, void *key) {
+    (void)type_descriptor;	/* Unused argument */
 	(void)struct_ptr;	/* Unused argument */
 	(void)cb;	/* Unused argument */
 	(void)key;	/* Unused argument */
@@ -28,15 +28,16 @@
 }
 
 struct errbufDesc {
-	asn_TYPE_descriptor_t *failed_type;
-	const void *failed_struct_ptr;
+    const asn_TYPE_descriptor_t *failed_type;
+    const void *failed_struct_ptr;
 	char *errbuf;
 	size_t errlen;
 };
 
 static void
-_asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const char *fmt, ...) {
-	struct errbufDesc *arg = key;
+_asn_i_ctfailcb(void *key, const asn_TYPE_descriptor_t *td, const void *sptr,
+                const char *fmt, ...) {
+    struct errbufDesc *arg = key;
 	va_list ap;
 	ssize_t vlen;
 	ssize_t maxlen;
@@ -73,7 +74,7 @@
 }
 
 int
-asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor,
+asn_check_constraints(const asn_TYPE_descriptor_t *type_descriptor,
                       const void *struct_ptr, char *errbuf, size_t *errlen) {
     struct errbufDesc arg;
     int ret;
diff --git a/skeletons/constraints.h b/skeletons/constraints.h
index 48d49e2..0bd86a9 100644
--- a/skeletons/constraints.h
+++ b/skeletons/constraints.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	ASN1_CONSTRAINTS_VALIDATOR_H
@@ -25,24 +25,23 @@
  * This function returns 0 in case all ASN.1 constraints are met
  * and -1 if one or more constraints were failed.
  */
-int
-asn_check_constraints(struct asn_TYPE_descriptor_s *type_descriptor,
-	const void *struct_ptr,	/* Target language's structure */
-	char *errbuf,		/* Returned error description */
-	size_t *errlen		/* Length of the error description */
-	);
+int asn_check_constraints(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr, /* Target language's structure */
+    char *errbuf,           /* Returned error description */
+    size_t *errlen          /* Length of the error description */
+);
 
 
 /*
  * Generic type for constraint checking callback,
  * associated with every type descriptor.
  */
-typedef int (asn_constr_check_f)(
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	const void *struct_ptr,
-	asn_app_constraint_failed_f *optional_callback,	/* Log the error */
-	void *optional_app_key		/* Opaque key passed to a callback */
-	);
+typedef int(asn_constr_check_f)(
+    const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr,
+    asn_app_constraint_failed_f *optional_callback, /* Log the error */
+    void *optional_app_key /* Opaque key passed to a callback */
+);
 
 /*******************************
  * INTERNALLY USEFUL FUNCTIONS *
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index a26d57e..2c6a6f7 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -12,19 +12,17 @@
  * The DER encoder of any type.
  */
 asn_enc_rval_t
-der_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
-	asn_app_consume_bytes_f *consume_bytes, void *app_key) {
-
-	ASN_DEBUG("DER encoder invoked for %s",
+der_encode(const asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr,
+           asn_app_consume_bytes_f *consume_bytes, void *app_key) {
+    ASN_DEBUG("DER encoder invoked for %s",
 		type_descriptor->name);
 
 	/*
 	 * Invoke type-specific encoder.
 	 */
-	return type_descriptor->op->der_encoder(type_descriptor,
-		struct_ptr,	/* Pointer to the destination structure */
-		0, 0,
-		consume_bytes, app_key);
+    return type_descriptor->op->der_encoder(
+        type_descriptor, struct_ptr, /* Pointer to the destination structure */
+        0, 0, consume_bytes, app_key);
 }
 
 /*
@@ -51,9 +49,9 @@
  * A variant of the der_encode() which encodes the data into the provided buffer
  */
 asn_enc_rval_t
-der_encode_to_buffer(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
-	void *buffer, size_t buffer_size) {
-	enc_to_buf_arg arg;
+der_encode_to_buffer(const asn_TYPE_descriptor_t *type_descriptor,
+                     const void *struct_ptr, void *buffer, size_t buffer_size) {
+    enc_to_buf_arg arg;
 	asn_enc_rval_t ec;
 
 	arg.buffer = buffer;
@@ -74,8 +72,8 @@
  * Write out leading TL[v] sequence according to the type definition.
  */
 ssize_t
-der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, int tag_mode,
-               int last_tag_form,
+der_write_tags(const asn_TYPE_descriptor_t *sd, size_t struct_length,
+               int tag_mode, int last_tag_form,
                ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */
                asn_app_consume_bytes_f *cb, void *app_key) {
 #define ASN1_DER_MAX_TAGS_COUNT 4
diff --git a/skeletons/der_encoder.h b/skeletons/der_encoder.h
index 68b9d5c..e93944e 100644
--- a/skeletons/der_encoder.h
+++ b/skeletons/der_encoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_DER_ENCODER_H_
@@ -20,31 +20,30 @@
  * NOTE: Use the ber_decode() function (ber_decoder.h) to decode data
  * produced by der_encode().
  */
-asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
-		void *struct_ptr,	/* Structure to be encoded */
-		asn_app_consume_bytes_f *consume_bytes_cb,
-		void *app_key		/* Arbitrary callback argument */
-	);
+asn_enc_rval_t der_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
+                          const void *struct_ptr, /* Structure to be encoded */
+                          asn_app_consume_bytes_f *consume_bytes_cb,
+                          void *app_key /* Arbitrary callback argument */
+);
 
 /* A variant of der_encode() which encodes data into the pre-allocated buffer */
 asn_enc_rval_t der_encode_to_buffer(
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		void *struct_ptr,	/* Structure to be encoded */
-		void *buffer,		/* Pre-allocated buffer */
-		size_t buffer_size	/* Initial buffer size (maximum) */
-	);
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr, /* Structure to be encoded */
+    void *buffer,           /* Pre-allocated buffer */
+    size_t buffer_size      /* Initial buffer size (maximum) */
+);
 
 /*
  * Type of the generic DER encoder.
  */
-typedef asn_enc_rval_t (der_type_encoder_f)(
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		void *struct_ptr,	/* Structure to be encoded */
-		int tag_mode,		/* {-1,0,1}: IMPLICIT, no, EXPLICIT */
-		ber_tlv_tag_t tag,
-		asn_app_consume_bytes_f *consume_bytes_cb,	/* Callback */
-		void *app_key		/* Arbitrary callback argument */
-	);
+typedef asn_enc_rval_t(der_type_encoder_f)(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr, /* Structure to be encoded */
+    int tag_mode,           /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
+    ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
+    void *app_key /* Arbitrary callback argument */
+);
 
 
 /*******************************
@@ -54,15 +53,13 @@
 /*
  * Write out leading TL[v] sequence according to the type definition.
  */
-ssize_t der_write_tags(
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		size_t struct_length,
-		int tag_mode,		/* {-1,0,1}: IMPLICIT, no, EXPLICIT */
-		int last_tag_form,	/* {0,!0}: prim, constructed */
-		ber_tlv_tag_t tag,
-		asn_app_consume_bytes_f *consume_bytes_cb,
-		void *app_key
-	);
+ssize_t der_write_tags(const struct asn_TYPE_descriptor_s *type_descriptor,
+                       size_t struct_length,
+                       int tag_mode,      /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
+                       int last_tag_form, /* {0,!0}: prim, constructed */
+                       ber_tlv_tag_t tag,
+                       asn_app_consume_bytes_f *consume_bytes_cb,
+                       void *app_key);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/oer_decoder.c b/skeletons/oer_decoder.c
index 52950f4..911a567 100644
--- a/skeletons/oer_decoder.c
+++ b/skeletons/oer_decoder.c
@@ -10,9 +10,9 @@
  */
 asn_dec_rval_t
 oer_decode(const asn_codec_ctx_t *opt_codec_ctx,
-	asn_TYPE_descriptor_t *type_descriptor,
-	void **struct_ptr, const void *ptr, size_t size) {
-	asn_codec_ctx_t s_codec_ctx;
+           const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
+           const void *ptr, size_t size) {
+    asn_codec_ctx_t s_codec_ctx;
 
 	/*
 	 * Stack checker requires that the codec context
@@ -58,7 +58,7 @@
  */
 ssize_t
 oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
-                  struct asn_TYPE_descriptor_s *td,
+                  const struct asn_TYPE_descriptor_s *td,
                   const asn_oer_constraints_t *constraints, void **struct_ptr,
                   const void *bufptr, size_t size) {
     asn_dec_rval_t dr;
@@ -96,7 +96,7 @@
 
 asn_dec_rval_t
 oer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
-                     asn_TYPE_descriptor_t *td,
+                     const asn_TYPE_descriptor_t *td,
                      const asn_oer_constraints_t *constraints, void **sptr,
                      const void *ptr, size_t size) {
     ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
diff --git a/skeletons/oer_decoder.h b/skeletons/oer_decoder.h
index 6c95d62..40992e9 100644
--- a/skeletons/oer_decoder.h
+++ b/skeletons/oer_decoder.h
@@ -21,7 +21,7 @@
  * Parses CANONICAL-OER and BASIC-OER.
  */
 asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
-	struct asn_TYPE_descriptor_s *type_descriptor,
+	const struct asn_TYPE_descriptor_s *type_descriptor,
 	void **struct_ptr,	/* Pointer to a target structure's pointer */
 	const void *buffer,	/* Data to be decoded */
 	size_t size		/* Size of that buffer */
@@ -32,7 +32,7 @@
  */
 typedef asn_dec_rval_t(oer_type_decoder_f)(
     const struct asn_codec_ctx_s *opt_codec_ctx,
-    struct asn_TYPE_descriptor_s *type_descriptor,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
     const asn_oer_constraints_t *constraints,
     void **struct_ptr,
     const void *buf_ptr,
@@ -55,7 +55,7 @@
  *      >0:     Number of bytes used from bufptr.
  */
 ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
-                          struct asn_TYPE_descriptor_s *td,
+                          const struct asn_TYPE_descriptor_s *td,
                           const asn_oer_constraints_t *constraints,
                           void **struct_ptr, const void *bufptr, size_t size);
 
diff --git a/skeletons/oer_encoder.c b/skeletons/oer_encoder.c
index d0e6ea0..4b7d7da 100644
--- a/skeletons/oer_encoder.c
+++ b/skeletons/oer_encoder.c
@@ -9,18 +9,17 @@
  * The OER encoder of any type.
  */
 asn_enc_rval_t
-oer_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
-        asn_app_consume_bytes_f *consume_bytes, void *app_key) {
+oer_encode(const asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr,
+           asn_app_consume_bytes_f *consume_bytes, void *app_key) {
+    ASN_DEBUG("OER encoder invoked for %s", type_descriptor->name);
 
-        ASN_DEBUG("OER encoder invoked for %s",
-                type_descriptor->name);
-
-        /*
-         * Invoke type-specific encoder.
-         */
-        return type_descriptor->op->oer_encoder(type_descriptor, 0,
-                struct_ptr,     /* Pointer to the destination structure */
-                consume_bytes, app_key);
+    /*
+     * Invoke type-specific encoder.
+     */
+    return type_descriptor->op->oer_encoder(
+        type_descriptor, 0,
+        struct_ptr, /* Pointer to the destination structure */
+        consume_bytes, app_key);
 }
 
 /*
@@ -30,29 +29,29 @@
         void *buffer;
         size_t left;
 } enc_to_buf_arg;
-static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
-        enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
+static int
+encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
+    enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
 
-        if(arg->left < size)
-                return -1;      /* Data exceeds the available buffer size */
+    if(arg->left < size) return -1; /* Data exceeds the available buffer size */
 
-        memcpy(arg->buffer, buffer, size);
-        arg->buffer = ((char *)arg->buffer) + size;
-        arg->left -= size;
+    memcpy(arg->buffer, buffer, size);
+    arg->buffer = ((char *)arg->buffer) + size;
+    arg->left -= size;
 
-        return 0;
+    return 0;
 }
 
 /*
  * A variant of the oer_encode() which encodes the data into the provided buffer
  */
 asn_enc_rval_t
-oer_encode_to_buffer(struct asn_TYPE_descriptor_s *type_descriptor,
+oer_encode_to_buffer(const asn_TYPE_descriptor_t *type_descriptor,
                      const asn_oer_constraints_t *constraints,
-                     void *struct_ptr,  /* Structure to be encoded */
-                     void *buffer,      /* Pre-allocated buffer */
-                     size_t buffer_size /* Initial buffer size (maximum) */
-                     ) {
+                     const void *struct_ptr, /* Structure to be encoded */
+                     void *buffer,           /* Pre-allocated buffer */
+                     size_t buffer_size      /* Initial buffer size (maximum) */
+) {
     enc_to_buf_arg arg;
     asn_enc_rval_t ec;
 
@@ -79,8 +78,8 @@
 }
 
 asn_enc_rval_t
-oer_encode_primitive(asn_TYPE_descriptor_t *td,
-                     const asn_oer_constraints_t *constraints, void *sptr,
+oer_encode_primitive(const asn_TYPE_descriptor_t *td,
+                     const asn_oer_constraints_t *constraints, const void *sptr,
                      asn_app_consume_bytes_f *cb, void *app_key) {
     const ASN__PRIMITIVE_TYPE_t *st = (const ASN__PRIMITIVE_TYPE_t *)sptr;
     asn_enc_rval_t er = {0, 0, 0};
@@ -112,30 +111,30 @@
 static int
 oer__count_bytes(const void *buffer, size_t size, void *bytes_ptr) {
     size_t *bytes = bytes_ptr;
+    (void)buffer;
     *bytes += size;
     return 0;
 }
 
 ssize_t
-oer_open_type_put(asn_TYPE_descriptor_t *td,
-                  const asn_oer_constraints_t *constraints,
-                  void *sptr, asn_app_consume_bytes_f *cb,
-                  void *app_key) {
+oer_open_type_put(const asn_TYPE_descriptor_t *td,
+                  const asn_oer_constraints_t *constraints, const void *sptr,
+                  asn_app_consume_bytes_f *cb, void *app_key) {
     size_t serialized_byte_count = 0;
     asn_enc_rval_t er;
     ssize_t len_len;
 
     er = td->op->oer_encoder(td, constraints, sptr, oer__count_bytes,
                              &serialized_byte_count);
-    if(er.encoded == -1) return -1;
-    assert(serialized_byte_count == er.encoded);
+    if(er.encoded < 0) return -1;
+    assert(serialized_byte_count == (size_t)er.encoded);
 
     len_len = oer_serialize_length(serialized_byte_count, cb, app_key);
     if(len_len == -1) return -1;
 
     er = td->op->oer_encoder(td, constraints, sptr, cb, app_key);
-    if(er.encoded == -1) return -1;
-    assert(serialized_byte_count == er.encoded);
+    if(er.encoded < 0) return -1;
+    assert(serialized_byte_count == (size_t)er.encoded);
 
     return er.encoded + len_len;
 }
diff --git a/skeletons/oer_encoder.h b/skeletons/oer_encoder.h
index 37d95e3..252bd6a 100644
--- a/skeletons/oer_encoder.h
+++ b/skeletons/oer_encoder.h
@@ -19,31 +19,31 @@
  * Produces CANONICAL-OER output compatible with CANONICAL-OER
  * and BASIC-OER decoders.
  */
-asn_enc_rval_t oer_encode(struct asn_TYPE_descriptor_s *type_descriptor,
-                          void *struct_ptr, /* Structure to be encoded */
+asn_enc_rval_t oer_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
+                          const void *struct_ptr, /* Structure to be encoded */
                           asn_app_consume_bytes_f *consume_bytes_cb,
                           void *app_key /* Arbitrary callback argument */
-                          );
+);
 
 /* A variant of oer_encode() which encodes data into the pre-allocated buffer */
 asn_enc_rval_t oer_encode_to_buffer(
-    struct asn_TYPE_descriptor_s *type_descriptor,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
     const asn_oer_constraints_t *constraints,
-    void *struct_ptr,  /* Structure to be encoded */
-    void *buffer,      /* Pre-allocated buffer */
-    size_t buffer_size /* Initial buffer size (maximum) */
-    );
+    const void *struct_ptr, /* Structure to be encoded */
+    void *buffer,           /* Pre-allocated buffer */
+    size_t buffer_size      /* Initial buffer size (maximum) */
+);
 
 /*
  * Type of the generic OER encoder.
  */
 typedef asn_enc_rval_t(oer_type_encoder_f)(
-    struct asn_TYPE_descriptor_s *type_descriptor,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
     const asn_oer_constraints_t *constraints,
-    void *struct_ptr,                          /* Structure to be encoded */
+    const void *struct_ptr,                    /* Structure to be encoded */
     asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
     void *app_key                              /* Arbitrary callback argument */
-    );
+);
 
 /*
  * Write out the Open Type (X.696 (08/2015), #30).
@@ -51,9 +51,9 @@
  *      -1:     Fatal error encoding the type.
  *     >=0:     Number of bytes serialized.
  */
-ssize_t oer_open_type_put(struct asn_TYPE_descriptor_s *td,
+ssize_t oer_open_type_put(const struct asn_TYPE_descriptor_s *td,
                           const asn_oer_constraints_t *constraints,
-                          void *struct_ptr,
+                          const void *struct_ptr,
                           asn_app_consume_bytes_f *consume_bytes_cb,
                           void *app_key);
 
diff --git a/skeletons/oer_support.h b/skeletons/oer_support.h
index 508ce64..dbc9b5f 100644
--- a/skeletons/oer_support.h
+++ b/skeletons/oer_support.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	OER_SUPPORT_H
diff --git a/skeletons/per_decoder.c b/skeletons/per_decoder.c
index 6fe71dc..a9051fb 100644
--- a/skeletons/per_decoder.c
+++ b/skeletons/per_decoder.c
@@ -8,8 +8,10 @@
  * multiple of 8 bytes.
  */
 asn_dec_rval_t
-uper_decode_complete(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size) {
-	asn_dec_rval_t rval;
+uper_decode_complete(const asn_codec_ctx_t *opt_codec_ctx,
+                     const asn_TYPE_descriptor_t *td, void **sptr,
+                     const void *buffer, size_t size) {
+    asn_dec_rval_t rval;
 
 	rval = uper_decode(opt_codec_ctx, td, sptr, buffer, size, 0, 0);
 	if(rval.consumed) {
@@ -37,8 +39,10 @@
 }
 
 asn_dec_rval_t
-uper_decode(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size, int skip_bits, int unused_bits) {
-	asn_codec_ctx_t s_codec_ctx;
+uper_decode(const asn_codec_ctx_t *opt_codec_ctx,
+            const asn_TYPE_descriptor_t *td, void **sptr, const void *buffer,
+            size_t size, int skip_bits, int unused_bits) {
+    asn_codec_ctx_t s_codec_ctx;
 	asn_dec_rval_t rval;
 	asn_per_data_t pd;
 
diff --git a/skeletons/per_decoder.h b/skeletons/per_decoder.h
index e97dd78..24dfe93 100644
--- a/skeletons/per_decoder.h
+++ b/skeletons/per_decoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2005, 2007 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_PER_DECODER_H_
@@ -20,11 +20,11 @@
  */
 asn_dec_rval_t uper_decode_complete(
     const struct asn_codec_ctx_s *opt_codec_ctx,
-    struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
+    const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
     void **struct_ptr,  /* Pointer to a target structure's pointer */
     const void *buffer, /* Data to be decoded */
     size_t size         /* Size of data buffer */
-    );
+);
 
 /*
  * Unaligned PER decoder of any ASN.1 type. May be invoked by the application.
@@ -32,13 +32,13 @@
  */
 asn_dec_rval_t uper_decode(
     const struct asn_codec_ctx_s *opt_codec_ctx,
-    struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
+    const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
     void **struct_ptr,  /* Pointer to a target structure's pointer */
     const void *buffer, /* Data to be decoded */
     size_t size,        /* Size of data buffer */
     int skip_bits,      /* Number of unused leading bits, 0..7 */
     int unused_bits     /* Number of unused tailing bits, 0..7 */
-    );
+);
 
 
 /*
@@ -46,7 +46,7 @@
  */
 typedef asn_dec_rval_t(per_type_decoder_f)(
     const asn_codec_ctx_t *opt_codec_ctx,
-    struct asn_TYPE_descriptor_s *type_descriptor,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
     const asn_per_constraints_t *constraints, void **struct_ptr,
     asn_per_data_t *per_data);
 
diff --git a/skeletons/per_encoder.c b/skeletons/per_encoder.c
index adee4e6..317897d 100644
--- a/skeletons/per_encoder.c
+++ b/skeletons/per_encoder.c
@@ -2,11 +2,16 @@
 #include <asn_internal.h>
 #include <per_encoder.h>
 
-static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
+static asn_enc_rval_t uper_encode_internal(const asn_TYPE_descriptor_t *td,
+                                           const asn_per_constraints_t *,
+                                           const void *sptr,
+                                           asn_app_consume_bytes_f *cb,
+                                           void *app_key);
 
 asn_enc_rval_t
-uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
-	return uper_encode_internal(td, 0, sptr, cb, app_key);
+uper_encode(const asn_TYPE_descriptor_t *td, const void *sptr,
+            asn_app_consume_bytes_f *cb, void *app_key) {
+    return uper_encode_internal(td, 0, sptr, cb, app_key);
 }
 
 /*
@@ -30,8 +35,9 @@
 }
 
 asn_enc_rval_t
-uper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr, void *buffer, size_t buffer_size) {
-	enc_to_buf_arg key;
+uper_encode_to_buffer(const asn_TYPE_descriptor_t *td, const void *sptr,
+                      void *buffer, size_t buffer_size) {
+    enc_to_buf_arg key;
 
 	key.buffer = buffer;
 	key.left = buffer_size;
@@ -65,9 +71,9 @@
 	return 0;
 }
 ssize_t
-uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td,
-                          const asn_per_constraints_t *constraints, void *sptr,
-                          void **buffer_r) {
+uper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
+                          const asn_per_constraints_t *constraints,
+                          const void *sptr, void **buffer_r) {
     asn_enc_rval_t er;
 	enc_dyn_arg key;
 
@@ -118,10 +124,10 @@
 }
 
 static asn_enc_rval_t
-uper_encode_internal(asn_TYPE_descriptor_t *td,
-                     const asn_per_constraints_t *constraints, void *sptr,
+uper_encode_internal(const asn_TYPE_descriptor_t *td,
+                     const asn_per_constraints_t *constraints, const void *sptr,
                      asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_per_outp_t po;
+    asn_per_outp_t po;
 	asn_enc_rval_t er;
 
 	/*
diff --git a/skeletons/per_encoder.h b/skeletons/per_encoder.h
index fd090ac..94177cf 100644
--- a/skeletons/per_encoder.h
+++ b/skeletons/per_encoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2006, 2007 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2006-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_PER_ENCODER_H_
@@ -20,10 +20,11 @@
  * field of the return value. Use the following formula to convert to bytes:
  * 	bytes = ((.encoded + 7) / 8)
  */
-asn_enc_rval_t uper_encode(struct asn_TYPE_descriptor_s *type_descriptor,
-	void *struct_ptr,	/* Structure to be encoded */
-	asn_app_consume_bytes_f *consume_bytes_cb,	/* Data collector */
-	void *app_key		/* Arbitrary callback argument */
+asn_enc_rval_t uper_encode(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr,                    /* Structure to be encoded */
+    asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */
+    void *app_key                              /* Arbitrary callback argument */
 );
 
 /*
@@ -32,10 +33,10 @@
  * field of the return value.
  */
 asn_enc_rval_t uper_encode_to_buffer(
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	void *struct_ptr,	/* Structure to be encoded */
-	void *buffer,		/* Pre-allocated buffer */
-	size_t buffer_size	/* Initial buffer size (max) */
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr, /* Structure to be encoded */
+    void *buffer,           /* Pre-allocated buffer */
+    size_t buffer_size      /* Initial buffer size (max) */
 );
 
 /*
@@ -46,21 +47,19 @@
  * encoding of uper_encode() and uper_encode_to_buffer().
  */
 ssize_t uper_encode_to_new_buffer(
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	const asn_per_constraints_t *constraints,
-	void *struct_ptr,	/* Structure to be encoded */
-	void **buffer_r		/* Buffer allocated and returned */
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const asn_per_constraints_t *constraints,
+    const void *struct_ptr, /* Structure to be encoded */
+    void **buffer_r         /* Buffer allocated and returned */
 );
 
 /*
  * Type of the generic PER encoder function.
  */
-typedef asn_enc_rval_t (per_type_encoder_f)(
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	const asn_per_constraints_t *constraints,
-	void *struct_ptr,
-	asn_per_outp_t *per_output
-);
+typedef asn_enc_rval_t(per_type_encoder_f)(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const asn_per_constraints_t *constraints, const void *struct_ptr,
+    asn_per_outp_t *per_output);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/per_opentype.c b/skeletons/per_opentype.c
index 70a1b44..353766a 100644
--- a/skeletons/per_opentype.c
+++ b/skeletons/per_opentype.c
@@ -17,7 +17,7 @@
 static int uper_ugot_refill(asn_per_data_t *pd);
 static int per_skip_bits(asn_per_data_t *pd, int skip_nbits);
 static asn_dec_rval_t uper_sot_suck(const asn_codec_ctx_t *,
-                                    asn_TYPE_descriptor_t *td,
+                                    const asn_TYPE_descriptor_t *td,
                                     const asn_per_constraints_t *constraints,
                                     void **sptr, asn_per_data_t *pd);
 
@@ -26,7 +26,9 @@
  * #10.1, #10.2
  */
 int
-uper_open_type_put(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) {
+uper_open_type_put(const asn_TYPE_descriptor_t *td,
+                   const asn_per_constraints_t *constraints, const void *sptr,
+                   asn_per_outp_t *po) {
     void *buf;
     void *bptr;
     ssize_t size;
@@ -62,9 +64,11 @@
 }
 
 static asn_dec_rval_t
-uper_open_type_get_simple(const asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
-	const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
-	asn_dec_rval_t rv;
+uper_open_type_get_simple(const asn_codec_ctx_t *ctx,
+                          const asn_TYPE_descriptor_t *td,
+                          const asn_per_constraints_t *constraints, void **sptr,
+                          asn_per_data_t *pd) {
+    asn_dec_rval_t rv;
 	ssize_t chunk_bytes;
 	int repeat;
 	uint8_t *buf = 0;
@@ -140,9 +144,11 @@
 }
 
 static asn_dec_rval_t CC_NOTUSED
-uper_open_type_get_complex(const asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
-	asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
-	uper_ugot_key arg;
+uper_open_type_get_complex(const asn_codec_ctx_t *ctx,
+                           const asn_TYPE_descriptor_t *td,
+                           asn_per_constraints_t *constraints, void **sptr,
+                           asn_per_data_t *pd) {
+    uper_ugot_key arg;
 	asn_dec_rval_t rv;
 	ssize_t padding;
 
@@ -250,7 +256,7 @@
 
 
 asn_dec_rval_t
-uper_open_type_get(const asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
+uper_open_type_get(const asn_codec_ctx_t *ctx, const asn_TYPE_descriptor_t *td,
                    const asn_per_constraints_t *constraints, void **sptr,
                    asn_per_data_t *pd) {
     return uper_open_type_get_simple(ctx, td, constraints, sptr, pd);
@@ -278,9 +284,10 @@
  */
 
 static asn_dec_rval_t
-uper_sot_suck(const asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
-	const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
-	asn_dec_rval_t rv;
+uper_sot_suck(const asn_codec_ctx_t *ctx, const asn_TYPE_descriptor_t *td,
+              const asn_per_constraints_t *constraints, void **sptr,
+              asn_per_data_t *pd) {
+    asn_dec_rval_t rv;
 
 	(void)ctx;
 	(void)td;
diff --git a/skeletons/per_opentype.h b/skeletons/per_opentype.h
index 31c1832..7e7dc61 100644
--- a/skeletons/per_opentype.h
+++ b/skeletons/per_opentype.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2007-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_PER_OPENTYPE_H_
@@ -10,7 +10,7 @@
 #endif
 
 asn_dec_rval_t uper_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
-                                  asn_TYPE_descriptor_t *td,
+                                  const asn_TYPE_descriptor_t *td,
                                   const asn_per_constraints_t *constraints,
                                   void **sptr, asn_per_data_t *pd);
 
@@ -21,9 +21,9 @@
  * X.691 (2015/08), #11.2
  * Returns -1 if error is encountered. 0 if all OK.
  */
-int uper_open_type_put(asn_TYPE_descriptor_t *td,
-                       const asn_per_constraints_t *constraints, void *sptr,
-                       asn_per_outp_t *po);
+int uper_open_type_put(const asn_TYPE_descriptor_t *td,
+                       const asn_per_constraints_t *constraints,
+                       const void *sptr, asn_per_outp_t *po);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/per_support.c b/skeletons/per_support.c
index 95af9f6..a1c7702 100644
--- a/skeletons/per_support.c
+++ b/skeletons/per_support.c
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2005-2014 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #include <asn_system.h>
diff --git a/skeletons/per_support.h b/skeletons/per_support.h
index 94dde9f..3e905a8 100644
--- a/skeletons/per_support.h
+++ b/skeletons/per_support.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2005-2014 Lev Walkin <vlm@lionet.info>.
- * All rights reserved.
+ * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_PER_SUPPORT_H_
diff --git a/skeletons/xer_decoder.c b/skeletons/xer_decoder.c
index 3ac6b6b..5b87703 100644
--- a/skeletons/xer_decoder.c
+++ b/skeletons/xer_decoder.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #include <asn_application.h>
@@ -11,9 +11,10 @@
  * Decode the XER encoding of a given type.
  */
 asn_dec_rval_t
-xer_decode(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
-		void **struct_ptr, const void *buffer, size_t size) {
-	asn_codec_ctx_t s_codec_ctx;
+xer_decode(const asn_codec_ctx_t *opt_codec_ctx,
+           const asn_TYPE_descriptor_t *td, void **struct_ptr,
+           const void *buffer, size_t size) {
+    asn_codec_ctx_t s_codec_ctx;
 
 	/*
 	 * Stack checker requires that the codec context
diff --git a/skeletons/xer_decoder.h b/skeletons/xer_decoder.h
index f865102..b951c41 100644
--- a/skeletons/xer_decoder.h
+++ b/skeletons/xer_decoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_XER_DECODER_H_
@@ -17,19 +17,20 @@
  * The XER decoder of any ASN.1 type. May be invoked by the application.
  * Decodes CANONICAL-XER and BASIC-XER.
  */
-asn_dec_rval_t xer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
-	struct asn_TYPE_descriptor_s *type_descriptor,
-	void **struct_ptr,	/* Pointer to a target structure's pointer */
-	const void *buffer,	/* Data to be decoded */
-	size_t size		/* Size of data buffer */
-	);
+asn_dec_rval_t xer_decode(
+    const struct asn_codec_ctx_s *opt_codec_ctx,
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    void **struct_ptr,  /* Pointer to a target structure's pointer */
+    const void *buffer, /* Data to be decoded */
+    size_t size         /* Size of data buffer */
+);
 
 /*
  * Type of the type-specific XER decoder function.
  */
 typedef asn_dec_rval_t(xer_type_decoder_f)(
     const asn_codec_ctx_t *opt_codec_ctx,
-    struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,
+    const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,
     const char *opt_mname, /* Member name */
     const void *buf_ptr, size_t size);
 
diff --git a/skeletons/xer_encoder.c b/skeletons/xer_encoder.c
index a655ae3..4b4891f 100644
--- a/skeletons/xer_encoder.c
+++ b/skeletons/xer_encoder.c
@@ -10,10 +10,10 @@
  * The XER encoder of any type. May be invoked by the application.
  */
 asn_enc_rval_t
-xer_encode(asn_TYPE_descriptor_t *td, void *sptr,
-	enum xer_encoder_flags_e xer_flags,
-		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn_enc_rval_t er = {0, 0, 0};
+xer_encode(const asn_TYPE_descriptor_t *td, const void *sptr,
+           enum xer_encoder_flags_e xer_flags, asn_app_consume_bytes_f *cb,
+           void *app_key) {
+    asn_enc_rval_t er = {0, 0, 0};
 	asn_enc_rval_t tmper;
 	const char *mname;
 	size_t mlen;
@@ -52,8 +52,8 @@
 }
 
 int
-xer_fprint(FILE *stream, asn_TYPE_descriptor_t *td, void *sptr) {
-	asn_enc_rval_t er;
+xer_fprint(FILE *stream, const asn_TYPE_descriptor_t *td, const void *sptr) {
+    asn_enc_rval_t er;
 
 	if(!stream) stream = stdout;
 	if(!td || !sptr)
@@ -95,8 +95,8 @@
 }
 
 enum xer_equivalence_e
-xer_equivalent(struct asn_TYPE_descriptor_s *td, void *struct1,
-               void *struct2, FILE *opt_debug_stream) {
+xer_equivalent(const struct asn_TYPE_descriptor_s *td, const void *struct1,
+               const void *struct2, FILE *opt_debug_stream) {
     struct xer_buffer xb1 = {0, 0, 0};
     struct xer_buffer xb2 = {0, 0, 0};
     asn_enc_rval_t e1, e2;
diff --git a/skeletons/xer_encoder.h b/skeletons/xer_encoder.h
index 81c0d0c..564eea7 100644
--- a/skeletons/xer_encoder.h
+++ b/skeletons/xer_encoder.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_XER_ENCODER_H_
@@ -24,12 +24,12 @@
  * The XER encoder of any type. May be invoked by the application.
  * Produces CANONICAL-XER and BASIC-XER depending on the (xer_flags).
  */
-asn_enc_rval_t xer_encode(struct asn_TYPE_descriptor_s *type_descriptor,
-		void *struct_ptr,	/* Structure to be encoded */
-		enum xer_encoder_flags_e xer_flags,
-		asn_app_consume_bytes_f *consume_bytes_cb,
-		void *app_key		/* Arbitrary callback argument */
-	);
+asn_enc_rval_t xer_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
+                          const void *struct_ptr, /* Structure to be encoded */
+                          enum xer_encoder_flags_e xer_flags,
+                          asn_app_consume_bytes_f *consume_bytes_cb,
+                          void *app_key /* Arbitrary callback argument */
+);
 
 /*
  * A helper function that uses XER encoding/decoding to verify that:
@@ -50,8 +50,8 @@
     XEQ_ROUND_TRIP_FAILED /* Bad round-trip */
 };
 enum xer_equivalence_e xer_equivalent(
-    struct asn_TYPE_descriptor_s *type_descriptor, void *struct1, void *struct2,
-    FILE *opt_debug_stream);
+    const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct1,
+    const void *struct2, FILE *opt_debug_stream);
 
 /*
  * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
@@ -61,19 +61,20 @@
  * 	-1: Problem printing the structure.
  * WARNING: No sensible errno value is returned.
  */
-int xer_fprint(FILE *stream, struct asn_TYPE_descriptor_s *td, void *sptr);
+int xer_fprint(FILE *stream, const struct asn_TYPE_descriptor_s *td,
+               const void *sptr);
 
 /*
  * Type of the generic XER encoder.
  */
-typedef asn_enc_rval_t (xer_type_encoder_f)(
-		struct asn_TYPE_descriptor_s *type_descriptor,
-		void *struct_ptr,	/* Structure to be encoded */
-		int ilevel,		/* Level of indentation */
-		enum xer_encoder_flags_e xer_flags,
-		asn_app_consume_bytes_f *consume_bytes_cb,	/* Callback */
-		void *app_key		/* Arbitrary callback argument */
-	);
+typedef asn_enc_rval_t(xer_type_encoder_f)(
+    const struct asn_TYPE_descriptor_s *type_descriptor,
+    const void *struct_ptr, /* Structure to be encoded */
+    int ilevel,             /* Level of indentation */
+    enum xer_encoder_flags_e xer_flags,
+    asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
+    void *app_key                              /* Arbitrary callback argument */
+);
 
 #ifdef __cplusplus
 }
diff --git a/skeletons/xer_support.h b/skeletons/xer_support.h
index 8b01944..c3a36e7 100644
--- a/skeletons/xer_support.h
+++ b/skeletons/xer_support.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com.
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
 #ifndef	_XER_SUPPORT_H_