Added clear cmd
added trim.c and cleaned up i/o