Added timeout as an option (so we can specify something else than 500ms).