Misc bugs corrected