Initial import of somewhat working code