improved code, put more into config, fixed some issues such as auto termination, need to move class into files once I know whether we create a new plugin for this