Major rewrite.