Sped up fillMatrix by using native trimLeft and trimRight methods, as well as by caching some results.
fixed bug where trimLeft and trimRight were swapped.
sped up trimming again.