Backport fixes and tallocisation of event.c from master