Force inline would probably be a good idea and state didn't seem to be initialized to 0 as I had expected.