added constants, comments, and some minor changes