KOTOR: More highlighting fixes.

This refactors some code and fixes some bugs I found. More highlighting stuff forthcoming.