Fixed some bugs

More to come...