More bug fixes