Bug Fixes for undefined variables in bck_relationship and bad prepare query