Code restructuring

- restructure the code to allow importing the correct functions into other scripts
- add --tab argument