Edited doc and cleaned some code.