simplified it a lot. Better CLI handling