Added CLI stuff and a bit of cleanup