Rewrite of core, including 8.1.0 compatibility