Second commit after 2 more hours of work.