various bugs merged