added (buggy) processing of commands;

need to fix endless loop;
added some debugging print statements;