Misc bug fix