Added bitmasks to byte conversions to avoid confusion.