Initial code dump, far from complete