Fix an ArrayIndexOutOfBoundsException

Address #26
Clean up various things