Bit setting stuff edited for legibility