Added comments, improved formating