Bug/misc fixes