Added endian swapping

Also added test code, and we have a mistake somewhere, the type list is complete nonsense ATM.