Complete rewrite of core system