Improve performance and code readability by using String's startsWith() method, other code improvements