Code simplifications and commenting