Now Command Line Tool

Changed to work as a simple command line tool, some code cleaned and
dumb memory wasting fixed.