added detailed comments for a bunch of stuff