Improved sqrt function. Made some memory changes.