cleanup and sqrt bugfixes