Fixes #2 - Replaced ArrayList with a queue

Improves performance.