Moved static variables to their usage as local variables
Parse command line in separate function
Split main() function into separate calls
- make a clean exit with atexit(cleanup)
- cleanup frees all resources
- create_res is now responsible for creating MonitorItems