moved flags encoding /decoding logic to flagsRegister