Fixed several BUGs