more bug fixes to pi