Fixed several errors