fix bugs caused by blind code-copying