Fixing NPE/index out of bounds

*Making command processing a little more resilient
*Should definitely start writing those tests sooner rather than later...