fixed buffer overruns; removed assumption regarding target endianness