Removed IsEmptyStr from some loops as its quicker this way (probably).