replaced for with foreach
made fields final where possible
made constants private where possible