First try
Final. Reformatting and comments