added more comments and improved layout a bit.