Fix handling of flags.

Now we always pass 0 as flags for extension callbacks, and just store
the result back into mflags/tflags. This way in the end we should get
the correct flags map, that can be passed to e.g. final_check().

Should fix #16.