Locating special events when solving ODEs