added record, minor modifications in eventloop