Removed explicit System.gc() call because it slowed things down.