byte swap functions refactored; added helper functions for swapping bytes in arrays