Refactored attribute handling. Fixes #307.
Respected byte order in string serialization. Fixes #306