code cleanup and edits to some methods.