Cleanup and reference fix