Added state fields and a bytes to int function