optimization level 2/3 fails to pass unit tests. need to investigate
fixes some silly mistakes references #229