Cleaned up a few lines, and added a few extra comments for clarity