Add some comments and make source more readable