Big cleanup when sending custom events

Also refactored the way buffers are swapped for the sessions. Now external code can write to writes without needing to care about which is active or not and no need to do "special" writers and such.