Fixed the error function and other things.