Fix indexing in TRAP and TAP