Fixed assorted bugs