Fixed bug in quality detection.