[AL] Move switch-case into element loop.

This results in fastest (in number of read instructions) code.
Add missing include.