Added in CLI mode detection, updated some comments and description, added in constructor and cleanup function.