more or less total code overhaul