fixed some bugs

main bug fix with not changing the reference signal and editing the
delay function