general overhaul of the code. Comments, unused variables...