Fixed several more bugs