misc bug fixing