Compiler Optimizations for the WAM