add start of more general Event code + wait() function
cleanup