Various bug fixes from Github