Fixed serveral serious errors