clean up, compliant v1, endianness fixed, shorter implentation: