Replaced ArryLists with arrays: 2 times speedup