Added begin/finish option & refactoring

- refactored code a bit
- added option to specify start/end of plot