Beginnings of error detection. Still a bit buggy, though.