Fix SQL bugs in bundle