packElement - buffer checks when serializing Code() and functions

Fix for #35.