Complete engine rewrite