bunch of fixes for bad ref and labels