Add some comments, make variables more readable, and add some tests