Rewrite code somewhat.