Fixing pg:delete + some script logic