Fixed the count cmd issue and changed other pieces of code.