Refactor byte swap; add unsigned data handling. Remove explicit cast.