Added comment to explain purpose of matrices.
Renamed variables for more clarity.
Replaced bitwise swap operation with a temporary variable.