Added more comments and did a general cleanup