Adding QC test functions and debugging