Fixed inlined reference counting: Store new refcount even if 0.
Fixed memory leaks due to wrong flags on stack entries.