Fixed several problems