Type casting reference matrix fixed.