add some more documentation
remove extra comma, whitespace
factor out some magic numbers