Move event detection functions to pystfio