Fixed StringIndexOutOfBoundsException

Closes dandelion/issues#140