Added additional cases and enabled GCC optimization.