more bug fixes and prolog changes