WIP: record events, bug fixes