Fixing out-of-range string indexing when trying to map a position. TODO: valgrind this library.