cleaned up, added comments.