Cleaning up unpacking code