Some refactoring, added a --terminal flag
Updated the documentation too