Rewrite code to match 0.11-pre
Not working due to a compiler bug