Cleaned out some legacy code and added additional comments.