xpath stuff & cleanup