[misc] Impove code style and performance: Replace Stack with Deque (mainly ArrayDeque)