Refactoring

- Use a lib instead of cramming everything into the bin/batchtapaper
  script
- Code style
- Lots of method extraction
- Better error handling
Merge pull request #1 from robmiller/refactoring

Refactoring