partially implemented traceForward and traceBackward, refactored stuff