Fix several more bugs