Fixed LinearSim. All test cases pass.