Minor hacks and bug fixes