Rewrite most parts with black magic