Cleanup and fixing algorthms