Added some comments and moved some things around.