added tappend, refactored out some ipairs, a minor bugfix

Updated previous pull request given comments in #3.