handle invalid json correctly by throwing a BadRequestException
fixed some inspection warnings