Mostly bug fixes