bmat case bug fixes