removed unused code, improved comments.