Reworked everything to use matrices instead of string manipulation.