Further cleaning, debuging and commenting